New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow join conditions to use an object. #743

Closed
whitelynx opened this Issue Mar 19, 2015 · 3 comments

Comments

Projects
None yet
3 participants
@whitelynx
Contributor

whitelynx commented Mar 19, 2015

Currently, join conditions may be specified in 3 ways:

knex.from('users').innerJoin('accounts', 'users.id', 'accounts.user_id')

knex.table('users').innerJoin('accounts', 'users.id', '=', 'accounts.user_id')

knex('users').innerJoin('accounts', function() {
  this.on('accounts.id', '=', 'users.account_id').orOn('accounts.owner_id', '=', 'users.id')
})

However, those familiar with .where() would expect a 4th possibility:

knex('users').innerJoin('accounts', {
  'accounts.id': 'users.account_id',
  'accounts.owner_id': 'users.id'
})

Could this syntax be added?

@bendrucker

This comment has been minimized.

Collaborator

bendrucker commented Mar 19, 2015

For sure. We'll definitely take a PR.

@tgriesser

This comment has been minimized.

Owner

tgriesser commented Mar 25, 2015

Wow that's such an obvious/better syntax. I'll definitely throw it on the list.

@tgriesser

This comment has been minimized.

Owner

tgriesser commented Apr 30, 2015

Available in 0.8

@tgriesser tgriesser closed this Apr 30, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment