mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge pull request #17469 from jamarzka/knex-join
knex: join supports object syntax when using a querybuilder
This commit is contained in:
Vendored
+2
-3
@@ -177,9 +177,8 @@ declare namespace Knex {
|
||||
|
||||
interface Join {
|
||||
(raw: Raw): QueryBuilder;
|
||||
(builder: QueryBuilder, clause: (this: JoinClause) => void): QueryBuilder;
|
||||
(tableName: string, columns: { [key: string]: string | number | Raw }): QueryBuilder;
|
||||
(tableName: string, callback: Function): QueryBuilder;
|
||||
(tableName: TableName, clause: (this: JoinClause) => void): QueryBuilder;
|
||||
(tableName: TableName, columns: { [key: string]: string | number | Raw }): QueryBuilder;
|
||||
(tableName: TableName, raw: Raw): QueryBuilder;
|
||||
(tableName: TableName, column1: string, column2: string): QueryBuilder;
|
||||
(tableName: TableName, column1: string, raw: Raw): QueryBuilder;
|
||||
|
||||
@@ -213,6 +213,14 @@ knex('users')
|
||||
.join(knex('contacts').select('user_id', 'phone').as('contacts'), 'users.id', 'contacts.user_id')
|
||||
.select('users.id', 'contacts.phone');
|
||||
|
||||
knex('users')
|
||||
.join(knex('contacts').select('user_id', 'phone').as('contacts'), { 'users.id': 'contacts.user_id' })
|
||||
.select('users.id', 'contacts.phone');
|
||||
|
||||
knex.select('*').from('users').join(knex('accounts').select('id', 'owner_id').as('accounts'), function() {
|
||||
this.on('accounts.id', '=', 'users.account_id').orOn('accounts.owner_id', '=', 'users.id')
|
||||
});
|
||||
|
||||
knex.select('*').from('users').join('accounts', function() {
|
||||
this.on('accounts.id', '=', 'users.account_id').orOn('accounts.owner_id', '=', 'users.id')
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user