UNPKG

mesa

Version:

simple elegant sql for nodejs

100 lines (96 loc) 2.98 kB
// Generated by CoffeeScript 1.10.0 var associations, mohair, slice = [].slice; mohair = require('mohair'); associations = require('./associations'); module.exports = { _mohair: mohair, _primaryKey: 'id', set: function(key, value) { var object; object = Object.create(this); object[key] = value; return object; }, connection: function(arg) { return this.set('_connection', arg); }, attributes: function(arg) { return this.set('_attributes', arg); }, primaryKey: function(arg) { return this.set('_primaryKey', arg); }, includes: function(arg) { return this.set('_includes', arg); }, table: function(arg) { return this.set('_table', arg).set('_mohair', this._mohair.table(arg)); }, sql: function() { return this._mohair.sql(); }, params: function() { return this._mohair.params(); }, raw: function() { var args, ref; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return (ref = this._mohair).raw.apply(ref, args); }, where: function() { var args, ref; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return this.set('_mohair', (ref = this._mohair).where.apply(ref, args)); }, join: function() { var args, ref; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return this.set('_mohair', (ref = this._mohair).join.apply(ref, args)); }, select: function() { var args, ref; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; return this.set('_mohair', (ref = this._mohair).select.apply(ref, args)); }, limit: function(arg) { return this.set('_mohair', this._mohair.limit(arg)); }, offset: function(arg) { return this.set('_mohair', this._mohair.offset(arg)); }, order: function(arg) { return this.set('_mohair', this._mohair.order(arg)); }, group: function(arg) { return this.set('_mohair', this._mohair.group(arg)); }, "with": function(arg) { return this.set('_mohair', this._mohair["with"](arg)); }, assertTable: function() { if (this._table == null) { throw new Error('mesa requires `table()` to be called before an insert, update or delete query'); } }, assertConnection: function() { if (this._connection == null) { throw new Error('mesa requires `connection()` to be called before any query'); } }, assertAttributes: function() { if (this._attributes == null) { throw new Error('mesa requires `attributes()` to be called before an insert or update query'); } }, enableConnectionReuseForIncludes: false, enableParallelIncludes: false, hasAssociated: associations.hasAssociated, hasOne: associations.hasOne, hasMany: associations.hasMany, belongsTo: associations.belongsTo, hasManyThrough: associations.hasManyThrough, hasOneThrough: associations.hasOneThrough, _getIncludes: associations._getIncludes, _prepareAssociatedTable: associations._prepareAssociatedTable };