diff --git a/definitions/npm/knex_v0.12.x/flow_v0.38.x-/knex_v0.12.x.js b/definitions/npm/knex_v0.12.x/flow_v0.38.x-/knex_v0.12.x.js index 65ed2db711..c2ddf5ad26 100644 --- a/definitions/npm/knex_v0.12.x/flow_v0.38.x-/knex_v0.12.x.js +++ b/definitions/npm/knex_v0.12.x/flow_v0.38.x-/knex_v0.12.x.js @@ -1,30 +1,37 @@ -declare class Knex$Transaction mixins Knex$QueryBuilder, events$EventEmitter, Promise { +declare class Knex$Migrate { + latest(): Promise, + rollback(): Promise +} + +declare type Knex$TransactionBody = (tx:Knex$Transaction) => Promise; +declare class Knex$Transaction mixins Knex$QueryBuilder, events$EventEmitter, Promise { commit(connection?: any, value?: any): Promise, rollback(): Promise, savepoint(connection?: any): Promise } -declare type Knex$QueryBuilderFn = ( - qb: Knex$QueryBuilder -) => Knex$QueryBuilder | void; +declare type Knex$QueryBuilderFn = ( + qb: Knex$QueryBuilder +) => Knex$QueryBuilder | void; -declare class Knex$QueryBuilder mixins Promise { +declare class Knex$QueryBuilder mixins Promise { select(key?: string[]): this, select(...key: string[]): this, timeout(ms: number, options?: { cancel: boolean }): this, column(key: string[]): this, column(...key: string[]): this, - with(alias: string, w: string | Knex$QueryBuilderFn): this, + with(alias: string, w: string | Knex$QueryBuilderFn): this, withSchema(schema: string): this, returning(column: string): this, returning(...columns: string[]): this, returning(columns: string[]): this, as(name: string): this, - transacting(trx: ?Knex$Transaction): this, - where(builder: Knex$QueryBuilderFn): this, + transacting(trx: ?Knex$Transaction): this, + where(builder: Knex$QueryBuilderFn): this, where(column: string, value: any): this, where(column: string, operator: string, value: any): this, - whereNot(builder: Knex$QueryBuilderFn): this, + where(conditions: {[column: string]: any}): this, + whereNot(builder: Knex$QueryBuilderFn): this, whereNot(column: string, value: any): this, whereNot(column: string, operator: string, value: any): this, whereIn(column: string, values: any[]): this, @@ -36,10 +43,10 @@ declare class Knex$QueryBuilder mixins Promise { whereBetween(column: string, range: number[]): this, whereNotBetween(column: string, range: number[]): this, whereRaw(sql: string, bindings?: Knex$RawBindings): this, - orWhere(builder: Knex$QueryBuilderFn): this, + orWhere(builder: Knex$QueryBuilderFn): this, orWhere(column: string, value: any): this, orWhere(column: string, operator: string, value: any): this, - orWhereNot(builder: Knex$QueryBuilderFn): this, + orWhereNot(builder: Knex$QueryBuilderFn): this, orWhereNot(column: string, value: any): this, orWhereNot(column: string, operator: string, value: any): this, orWhereIn(column: string, values: any[]): this, @@ -53,30 +60,30 @@ declare class Knex$QueryBuilder mixins Promise { orWhereRaw(sql: string, bindings?: Knex$RawBindings): this, innerJoin(table: string, c1: string, operator: string, c2: string): this, innerJoin(table: string, c1: string, c2: string): this, - innerJoin(builder: Knex$QueryBuilder | Knex$QueryBuilderFn, c1?: string, c2?: string): this, - innerJoin(table: string, builder: Knex$QueryBuilderFn): this, + innerJoin(builder: Knex$QueryBuilder, c1?: string, c2?: string): this, + innerJoin(table: string, builder: Knex$QueryBuilderFn): this, leftJoin(table: string, c1: string, operator: string, c2: string): this, leftJoin(table: string, c1: string, c2: string): this, - leftJoin(builder: Knex$QueryBuilder): this, - leftJoin(table: string, builder: Knex$QueryBuilderFn): this, + leftJoin(builder: Knex$QueryBuilder): this, + leftJoin(table: string, builder: Knex$QueryBuilderFn): this, leftOuterJoin(table: string, c1: string, operator: string, c2: string): this, leftOuterJoin(table: string, c1: string, c2: string): this, - leftOuterJoin(table: string, builder: Knex$QueryBuilderFn): this, + leftOuterJoin(table: string, builder: Knex$QueryBuilderFn): this, rightJoin(table: string, c1: string, operator: string, c2: string): this, rightJoin(table: string, c1: string, c2: string): this, - rightJoin(table: string, builder: Knex$QueryBuilderFn): this, + rightJoin(table: string, builder: Knex$QueryBuilderFn): this, rightOuterJoin(table: string, c1: string, operator: string, c2: string): this, rightOuterJoin(table: string, c1: string, c2: string): this, - rightOuterJoin(table: string, builder: Knex$QueryBuilderFn): this, + rightOuterJoin(table: string, builder: Knex$QueryBuilderFn): this, outerJoin(table: string, c1: string, operator: string, c2: string): this, outerJoin(table: string, c1: string, c2: string): this, - outerJoin(table: string, builder: Knex$QueryBuilderFn): this, + outerJoin(table: string, builder: Knex$QueryBuilderFn): this, fullOuterJoin(table: string, c1: string, operator: string, c2: string): this, fullOuterJoin(table: string, c1: string, c2: string): this, - fullOuterJoin(table: string, builder: Knex$QueryBuilderFn): this, + fullOuterJoin(table: string, builder: Knex$QueryBuilderFn): this, crossJoin(column: string, c1: string, c2: string): this, crossJoin(column: string, c1: string, operator: string, c2: string): this, - crossJoin(table: string, builder: Knex$QueryBuilderFn): this, + crossJoin(table: string, builder: Knex$QueryBuilderFn): this, joinRaw(sql: string, bindings?: Knex$RawBindings): this, distinct(): this, groupBy(column: string): this, @@ -90,8 +97,8 @@ declare class Knex$QueryBuilder mixins Promise { havingNotIn(column: string, values: Array): this, havingNull(column: string): this, havingNotNull(column: string): this, - havingExists(builder: Knex$QueryBuilderFn | Knex$QueryBuilder): this, - havingNotExists(builder: Knex$QueryBuilderFn | Knex$QueryBuilder): this, + havingExists(builder: Knex$QueryBuilderFn | Knex$QueryBuilder): this, + havingNotExists(builder: Knex$QueryBuilderFn | Knex$QueryBuilder): this, havingBetween(column: string, range: [T, T]): this, havingNotBetween(column: string, range: [T, T]): this, havingRaw(column: string, operator: string, value: mixed): this, @@ -110,23 +117,24 @@ declare class Knex$QueryBuilder mixins Promise { pluck(column: string): this, first(): this, from(table: string): this, - from(builder: Knex$QueryBuilderFn | Knex$Knex | Knex$QueryBuilder): this, - - insert(val: Object | Object[]): this, + from(builder: Knex$QueryBuilderFn | Knex$Knex | Knex$QueryBuilder): this, + insert(val: Object | Object[], returning?: string|Array): this, del(): this, delete(): this, update(column: string, value: any): this, - update(val: Object): this, + update(val: Object, returning?: string|Array): this, returning(columns: string[]): this } -declare class Knex$Knex mixins Knex$QueryBuilder, Promise, events$EventEmitter { - static (config: Knex$Config): Knex$Knex, +declare class Knex$Knex mixins Knex$QueryBuilder, Promise, events$EventEmitter { + static (config: Knex$Config): Knex$Knex, static QueryBuilder: typeof Knex$QueryBuilder, - $call: (tableName: string) => Knex$QueryBuilder, + $call: (tableName: string) => Knex$QueryBuilder, raw(sqlString: string, bindings?: Knex$RawBindings): any, client: any, - destroy(): Promise + destroy(): Promise, + transaction(run:Knex$TransactionBody): Knex$Transaction, + migrate: Knex$Migrate } declare type Knex$PostgresConfig = { @@ -184,6 +192,7 @@ declare module 'knex' { line: string, routine: string }; - declare type $QueryBuilder = Knex$QueryBuilder; + declare export type $Transaction = Knex$Transaction; + declare export type $QueryBuilder = Knex$QueryBuilder; declare var exports: typeof Knex$Knex; } diff --git a/definitions/npm/knex_v0.12.x/test_knex-v0.12.js b/definitions/npm/knex_v0.12.x/test_knex-v0.12.js index efe9b50e4b..762b19ec5a 100644 --- a/definitions/npm/knex_v0.12.x/test_knex-v0.12.js +++ b/definitions/npm/knex_v0.12.x/test_knex-v0.12.js @@ -38,6 +38,15 @@ knex.crossJoin('bar', function() { knex('foo').insert({ a: 1, }); +knex('foo').insert({a: 1}, 'name'); + +const q = knex('foo') + .update({a: 1}) + .where({b: 2}); +knex('foo') + .update({a: 1}, 'c') + .where({b: 2}); + knex('bar').del(); // $ExpectError knex.from();