@koober/database-client
Database client library
Last updated a month ago by alexandrech .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @koober/database-client 
SYNC missed versions from official npm registry.

Plop Documentation plugin (@koober/database-client)

NPM Version License

Database client library

Installation

npm install --save-dev @koober/database-client

Usage

import { SQL, executeQuery, Environment, createEnvironment } from '@koober/database-client';

interface User {
  id: number;
  name: string;
}

export async function getUserById(environment: Environment, id: number): Promise<User | null> {
  const sqlStatement = SQL`SELECT id, name FROM user WHERE id=${id}`;
  const rows = await executeQuery(environment, sqlStatement);

  return Array.isArray(rows) ? rows[0] : undefined;
}

export async function main(): Promise<void> {
  const environment = createEnvironment({
    adapter: 'mysql',
    database: '',
    user: '',
  });

  const response = await getUserById(environment, 123);
  console.log(response);
}

License

MIT © Julien Polo julien.polo@koober.com

Current Tags

  • 1.0.0-alpha.2                                ...           latest (a month ago)

2 Versions

  • 1.0.0-alpha.2                                ...           a month ago
  • 1.0.0-alpha.1                                ...           2 months ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 9
Dependencies (6)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |