1.0.0-rc.54 • Published 4 years ago
@koober/database-client v1.0.0-rc.54
Generic Database client (@koober/database-client)
Database client library
Installation
npm install @koober/database-client
Usage
import { SQL, executeQuery, DatabaseClient } from '@koober/database-client';
import { runTask, Task } from '@koober/std';
interface User {
id: number;
name: string;
}
export function getUserById(client: DatabaseClient, id: User['id']) {
const sqlStatement = SQL`SELECT id, name FROM user WHERE id=${id}`;
const task = executeQuery(client, sqlStatement);
return Task.map(task, (rows) => {
return Array.isArray(rows) ? (rows[0] as User) : undefined;
});
}
export async function main(): Promise<void> {
const client: DatabaseClient = {
databaseType: 'mysql',
database: '',
user: '',
};
const response = getUserById(client, 123);
console.log(await runTask(response));
}
License
MIT © Julien Polo julien.polo@koober.com
1.0.0-rc.54
4 years ago
1.0.0-rc.53
4 years ago
1.0.0-rc.51
4 years ago
1.0.0-rc.50
4 years ago
1.0.0-rc.49
4 years ago
1.0.0-rc.48
4 years ago
1.0.0-rc.47
4 years ago
1.0.0-rc.46
4 years ago
1.0.0-rc.42
4 years ago
1.0.0-rc.45
4 years ago
1.0.0-rc.44
4 years ago
1.0.0-rc.43
4 years ago
1.0.0-rc.41
4 years ago
1.0.0-rc.40
4 years ago
1.0.0-rc.39
4 years ago
1.0.0-rc.38
4 years ago
1.0.0-rc.31
4 years ago
1.0.0-rc.30
4 years ago
1.0.0-rc.32
4 years ago
1.0.0-rc.28
4 years ago
1.0.0-rc.29
4 years ago
1.0.0-alpha.3
4 years ago
1.0.0-alpha.2
5 years ago
1.0.0-alpha.1
5 years ago