Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function install () {
Object.defineProperty(knex.Client.prototype, 'tenantId', {
get: function() {
return this.config.tenantId;
},
});
override(QueryBuilder.prototype, 'toSQL', after(function(sql) {
debug('knex.Client.prototype.QueryBuilder.prototype.toSQL', arguments);
sql.sql = applyTenant(sql.sql, this.client.tenantId);
return sql;
}));
override(Raw.prototype, 'set', before(function(sql, bindings) {
debug('knex.Client.prototype.Raw.prototype.set', arguments);
const tenantSQL = applyTenant(sql, this.client.tenantId);
return [tenantSQL, bindings];
}));