knex/lib/raw.js

44 lines
873 B
JavaScript
Raw Normal View History

2013-09-13 16:58:38 -04:00
// Raw
// -------
(function(define) {
"use strict";
define(function(require, exports) {
var _ = require('underscore');
var Common = require('./common').Common;
2013-09-05 16:36:49 -04:00
var Raw = function(instance) {
this.knex = instance;
this.client = instance.client;
this.flags = {};
};
2013-09-05 16:36:49 -04:00
_.extend(Raw.prototype, Common, {
_source: 'Raw',
2013-09-05 16:36:49 -04:00
// 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;
}
});
exports.Raw = Raw;
});
})(
2013-09-05 16:36:49 -04:00
typeof define === 'function' && define.amd ? define : function (factory) { factory(require, exports); }
);