mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Note that this *trivially* updates project urls by adding the NPM url to the end, even when the urls are almost identical or the DT one is outdated. I'll clean up the urls in a later commit. This PR is unfinished! Please do not merge it yet.
70 lines
2.3 KiB
TypeScript
70 lines
2.3 KiB
TypeScript
// Type definitions for node-crate 2.0
|
|
// Project: https://github.com/megastef/node-crate, http://megastef.github.io/node-crate
|
|
// Definitions by: Greg Jednaszewski <https://github.com/gjednaszewski>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
// TypeScript Version: 2.2
|
|
|
|
declare namespace crate {
|
|
interface DBResultObject {
|
|
json: object[];
|
|
duration: number;
|
|
rowcount: number;
|
|
cols: string[];
|
|
rows: object[][];
|
|
}
|
|
|
|
interface Crate {
|
|
/**
|
|
* Connect to a single crate instance with host and port
|
|
*/
|
|
connect: (host: string, port?: number) => void;
|
|
/**
|
|
* Executes a parameterized sql statement.
|
|
*/
|
|
execute: (sql: string, args?: Array<string|number|Date>) => Promise<DBResultObject>;
|
|
/**
|
|
* Inserts a row in table.
|
|
*/
|
|
insert: (tableName: string, data: object) => Promise<DBResultObject>;
|
|
/**
|
|
* Creates a table with the given schema.
|
|
*/
|
|
create: (schema: object) => Promise<DBResultObject>;
|
|
/**
|
|
* Creates a table if it doesn't already exist.
|
|
*/
|
|
createIfNotExists: (schema: object) => Promise<DBResultObject>;
|
|
/**
|
|
* Drops a table.
|
|
*/
|
|
drop: (tableName: string) => Promise<DBResultObject>;
|
|
/**
|
|
* Updates one or more rows in table.
|
|
*/
|
|
update: (tableName: string, data: object, where: string) => Promise<DBResultObject>;
|
|
/**
|
|
* Deletes one or more rows in a table.
|
|
*/
|
|
delete: (tableName: string, where: string) => Promise<DBResultObject>;
|
|
/**
|
|
* Creates a BLOB table
|
|
*/
|
|
createBlobTable: (tableName: string, replicas: number, shards: number) => Promise<DBResultObject>;
|
|
/**
|
|
* Inserts a BLOB
|
|
*/
|
|
insertBlob: (tableName: string, buffer: string) => Promise<string>;
|
|
/**
|
|
* Inserts a BLOB from the filesystem
|
|
*/
|
|
insertBlobFile: (tableName: string, filename: string) => Promise<string>;
|
|
/**
|
|
* Retrieves a BLOB with the given hash key
|
|
*/
|
|
getBlob: (tableName: string, hashKey: string) => Promise<string>;
|
|
}
|
|
}
|
|
|
|
declare var crate: crate.Crate;
|
|
export = crate;
|