// Type definitions for node-crate 2.0 // Project: https://github.com/megastef/node-crate, http://megastef.github.io/node-crate // Definitions by: Greg Jednaszewski // 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) => Promise; /** * Inserts a row in table. */ insert: (tableName: string, data: object) => Promise; /** * Creates a table with the given schema. */ create: (schema: object) => Promise; /** * Creates a table if it doesn't already exist. */ createIfNotExists: (schema: object) => Promise; /** * Drops a table. */ drop: (tableName: string) => Promise; /** * Updates one or more rows in table. */ update: (tableName: string, data: object, where: string) => Promise; /** * Deletes one or more rows in a table. */ delete: (tableName: string, where: string) => Promise; /** * Creates a BLOB table */ createBlobTable: (tableName: string, replicas: number, shards: number) => Promise; /** * Inserts a BLOB */ insertBlob: (tableName: string, buffer: string) => Promise; /** * Inserts a BLOB from the filesystem */ insertBlobFile: (tableName: string, filename: string) => Promise; /** * Retrieves a BLOB with the given hash key */ getBlob: (tableName: string, hashKey: string) => Promise; } } declare var crate: crate.Crate; export = crate;