-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
Description
It would be great if you could do something like
var query = knex('users').select('username');
var admins = query.where('account_type', 0);
var me = query.where('username', 'jamesrom');
var others = query.where('account_type', '>', 0);Notice how I'm reusing query with different where clauses. This would mean that the query builder methods would return a new query builder object, not modify the original.
An alternative and simplier solution could be a .clone() method (similar to jQuery, momentjs, etc) that returns a clone of the query builder object.
var query = knex('users').select('username');
var admins = query.clone().where('account_type', 0);
var me = query.clone().where('username', 'jamesrom');
var others = query.clone().where('account_type', '>', 0);