[Knex] add batch builder typedef for knex (#14760)

* add batch builder typedef for knex

* fix spacing
This commit is contained in:
Chet Husk 2017-03-10 17:58:48 -06:00 committed by Mohamed Hegazy
parent c73a528e27
commit c0948a79a2
2 changed files with 4 additions and 2 deletions

4
knex/index.d.ts vendored
View File

@ -1,6 +1,6 @@
// Type definitions for Knex.js
// Project: https://github.com/tgriesser/knex
// Definitions by: Qubo <https://github.com/tkQubo>
// Definitions by: Qubo <https://github.com/tkQubo>, Baronfel <https://github.com/baronfel>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
@ -25,7 +25,7 @@ interface Knex extends Knex.QueryInterface {
transaction: <R>(transactionScope: ((trx: Knex.Transaction) => void)) => Promise<any>;
destroy(callback: Function): void;
destroy(): Promise<void>;
batchInsert(tableName : TableName, data: any[], chunkSize : number) : Knex.QueryBuilder;
schema: Knex.SchemaBuilder;
client: any;

View File

@ -285,6 +285,8 @@ knex('books')
.returning('id')
.insert([{title: 'Great Gatsby'}, {title: 'Fahrenheit 451'}]);
knex.batchInsert('books', [{title:'Great Gatsby'}, {title: 'Fahrenheit 451'}], 200);
knex('books').where('published_date', '<', 2000).update({status: 'archived'});
knex('books').where('published_date', '<', 2000).update({status: 'archived'}, 'id');
knex('books').where('published_date', '<', 2000).update({status: 'archived'}, ['id', 'title']);