diff --git a/types/knex/index.d.ts b/types/knex/index.d.ts index b400af2497..329bf438b2 100644 --- a/types/knex/index.d.ts +++ b/types/knex/index.d.ts @@ -156,7 +156,6 @@ declare namespace Knex { // Others first: Select; - debug(enabled?: boolean): QueryBuilder; pluck(column: string): QueryBuilder; insert(data: any, returning?: string | string[]): QueryBuilder; @@ -169,9 +168,6 @@ declare namespace Knex { delete(returning?: string | string[]): QueryBuilder; truncate(): QueryBuilder; - transacting(trx?: Transaction): QueryBuilder; - connection(connection: any): QueryBuilder; - clone(): QueryBuilder; } @@ -390,12 +386,14 @@ declare namespace Knex { interface ChainableInterface extends Bluebird { toQuery(): string; - options(options: any): QueryBuilder; - stream(callback: (readable: stream.PassThrough) => any): Bluebird; + options(options: { [key: string]: any }): this; + connection(connection: any): this; + debug(enabled: boolean): this; + transacting(trx: Transaction): this; + stream(handler: (readable: stream.PassThrough) => any): Bluebird; + stream(options: { [key: string]: any }, handler: (readable: stream.PassThrough) => any): Bluebird; stream(options?: { [key: string]: any }): stream.PassThrough; - stream(options: { [key: string]: any }, callback: (readable: stream.PassThrough) => any): Bluebird; - pipe(writable: any): stream.PassThrough; - exec(callback: Function): QueryBuilder; + pipe(writable: T, options?: { [key: string]: any }): stream.PassThrough; } interface Transaction extends Knex { @@ -408,7 +406,7 @@ declare namespace Knex { // Schema builder // - interface SchemaBuilder extends Bluebird { + interface SchemaBuilder extends ChainableInterface { createTable(tableName: string, callback: (tableBuilder: CreateTableBuilder) => any): SchemaBuilder; createTableIfNotExists(tableName: string, callback: (tableBuilder: CreateTableBuilder) => any): SchemaBuilder; alterTable(tableName: string, callback: (tableBuilder: CreateTableBuilder) => any): SchemaBuilder; diff --git a/types/knex/knex-tests.ts b/types/knex/knex-tests.ts index e7fb3e1b81..461e1738fe 100644 --- a/types/knex/knex-tests.ts +++ b/types/knex/knex-tests.ts @@ -982,19 +982,11 @@ knex.select('name').from('users') .where('id', '>', 20) .andWhere('id', '<', 200) .limit(10) - .offset(x) - .exec(function(err: any, rows: any[]) { - if (err) return console.error(err); - knex.select('id').from('nicknames').whereIn('nickname', rows.map((r: any) => r.name)) - .exec(function(err: any, rows: any[]) { - if (err) return console.error(err); - console.log(rows); - }); - }); + .offset(x); // Retrieve the stream: var stream = knex.select('*').from('users').stream(); -var writableStream: any; +var writableStream: NodeJS.WritableStream; stream.pipe(writableStream); // With options: