knex/clients/server/sqlite3/schemagrammar.js
Tim Griesser ee1efa50e3 Attaching grammars directly onto client instances, fixes #74
Allows passing in an intitialized client instance to the constructor
2013-09-17 06:54:26 -04:00

18 lines
560 B
JavaScript

var baseSchemaGrammar = require('../../base/sqlite3/schemagrammar').schemaGrammar;
exports.schemaGrammar = _.defaults({
handleResponse: function(builder, resp) {
// This is an array, so we'll assume that the relevant info is on the first statement...
resp = resp[0];
var ctx = resp[1]; resp = resp[0];
if (builder.type === 'tableExists') {
return resp.length > 0;
} else if (builder.type === 'columnExists') {
return _.findWhere(resp, {name: builder.bindings[1]}) != null;
}
return resp;
}
}, baseSchemaGrammar);