sqlify
Version:
Yet another SQL query builder for Node.js
25 lines • 855 B
JavaScript
;
/**
* implementing: WHERE
* https://hiddentao.com/squel/api.html#select_where
*/
Object.defineProperty(exports, "__esModule", { value: true });
var appendingValue = '';
exports.where = function (chain, resource) {
Object.keys(resource).forEach(function (item) {
appendingValue = resource[item];
// modify appendingValue to include 's if necessary
switch (typeof resource[item]) {
case 'number':
case 'boolean':
break;
case 'string':
appendingValue = "'" + appendingValue + "'";
break;
default:
throw new Error('SQLIFY ERR: a type other than "string", "number", "boolean" encountered');
}
chain = chain.where(item + '=' + appendingValue);
});
};
//# sourceMappingURL=where.js.map