mirror of
https://github.com/knex/knex.git
synced 2025-07-20 07:21:15 +00:00

When this eventually enabled on the client side, we can build this into the build script.
39 lines
779 B
JavaScript
39 lines
779 B
JavaScript
// Raw
|
|
// -------
|
|
var _ = require('lodash');
|
|
|
|
var Common = require('./common').Common;
|
|
|
|
var Raw = function(instance) {
|
|
this.knex = instance;
|
|
this.client = instance.client;
|
|
this.flags = {};
|
|
};
|
|
|
|
_.extend(Raw.prototype, Common, {
|
|
|
|
_source: 'Raw',
|
|
|
|
// Set the sql and the bindings associated with the query, returning
|
|
// the current raw object.
|
|
query: function(sql, bindings) {
|
|
this.bindings = _.isArray(bindings) ? bindings :
|
|
bindings ? [bindings] : [];
|
|
this.sql = sql;
|
|
return this;
|
|
},
|
|
|
|
// Returns the raw sql for the query.
|
|
toSql: function() {
|
|
return this.sql;
|
|
},
|
|
|
|
// Returns the cleaned bindings for the current raw query.
|
|
getBindings: function() {
|
|
return this.client.grammar.getBindings(this);
|
|
}
|
|
|
|
});
|
|
|
|
exports.Raw = Raw;
|