Comparing version 0.8.12 to 0.8.13
@@ -91,2 +91,14 @@ To query, create a query object using [[#ModelQuery.query]] first. | ||
<tr> | ||
<td rowspan='2'>Regular expression</td> | ||
<td>name: /smi/</td> | ||
<td>name REGEXP 'smi'</td> | ||
<td>{ name: /smi/i }</td> | ||
</tr> | ||
<tr> | ||
<td>name: /smi|doe/</td> | ||
<td>name REGEXP 'smi|doe'</td> | ||
<td>{ name: /smi|doe/i }</td> | ||
</tr> | ||
<tr> | ||
<td rowspan='2'>Matches any of an array</td> | ||
@@ -93,0 +105,0 @@ <td>age: { $in: [ 10, 20, 30 ] }</td> |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -141,2 +141,6 @@ var AdapterBase, async, types, util; | ||
AdapterBase.prototype.upsert = function(model, data, conditions, options, callback) { | ||
return callback(new Error('not implemented')); | ||
}; | ||
AdapterBase.prototype.findById = function(model, id, options, callback) { | ||
@@ -150,3 +154,3 @@ return callback(new Error('not implemented')); | ||
AdapterBase.prototype.count = function(model, conditions, callback) { | ||
AdapterBase.prototype.count = function(model, conditions, options, callback) { | ||
return callback(new Error('not implemented')); | ||
@@ -153,0 +157,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -190,2 +190,6 @@ var AdapterBase, CormoTypesObjectId, MongoDBAdapter, ObjectID, _, _buildGroupFields, _buildWhere, _buildWhereSingle, _convertValueToObjectID, _objectIdToString, async, error, mongodb, types, | ||
} | ||
} else if (_.isRegExp(value)) { | ||
if (!value.ignoreCase) { | ||
value = new RegExp(value.source, 'i'); | ||
} | ||
} else { | ||
@@ -581,2 +585,49 @@ if (is_objectid && (value != null)) { | ||
MongoDBAdapter.prototype.upsert = function(model, data, conditions, options, callback) { | ||
var e, key, schema, update_ops, value; | ||
schema = this._connection.models[model]._schema; | ||
try { | ||
conditions = _buildWhere(schema, conditions); | ||
} catch (_error) { | ||
e = _error; | ||
return callback(e); | ||
} | ||
if (!conditions) { | ||
conditions = {}; | ||
} | ||
update_ops = { | ||
$set: {}, | ||
$unset: {}, | ||
$inc: {} | ||
}; | ||
for (key in conditions) { | ||
value = conditions[key]; | ||
update_ops.$set[key] = value; | ||
} | ||
this._buildUpdateOps(schema, update_ops, data, '', data); | ||
if (Object.keys(update_ops.$set).length === 0) { | ||
delete update_ops.$set; | ||
} | ||
if (Object.keys(update_ops.$unset).length === 0) { | ||
delete update_ops.$unset; | ||
} | ||
if (Object.keys(update_ops.$inc).length === 0) { | ||
delete update_ops.$inc; | ||
} | ||
return this._collection(model).update(conditions, update_ops, { | ||
safe: true, | ||
upsert: true | ||
}, function(error, result) { | ||
var ref; | ||
if ((ref = error != null ? error.code : void 0) === 11001 || ref === 11000) { | ||
key = error.message.match(/index: [\w-.]+\$(\w+)_1/); | ||
return callback(new Error('duplicated ' + (key != null ? key[1] : void 0))); | ||
} | ||
if (error) { | ||
return callback(MongoDBAdapter.wrapError('unknown error', error)); | ||
} | ||
return callback(null); | ||
}); | ||
}; | ||
MongoDBAdapter.prototype.findById = function(model, id, options, callback) { | ||
@@ -796,4 +847,4 @@ var client_options, e, fields; | ||
MongoDBAdapter.prototype.count = function(model, conditions, callback) { | ||
var e; | ||
MongoDBAdapter.prototype.count = function(model, conditions, options, callback) { | ||
var e, pipeline; | ||
try { | ||
@@ -805,10 +856,46 @@ conditions = _buildWhere(this._connection.models[model]._schema, conditions); | ||
} | ||
return this._collection(model).count(conditions, (function(_this) { | ||
return function(error, count) { | ||
if (error) { | ||
return callback(MongoDBAdapter.wrapError('unknown error', error)); | ||
if (options.group_by || options.group_fields) { | ||
pipeline = []; | ||
if (conditions) { | ||
pipeline.push({ | ||
$match: conditions | ||
}); | ||
} | ||
pipeline.push({ | ||
$group: _buildGroupFields(options.group_by, options.group_fields) | ||
}); | ||
if (options.conditions_of_group.length > 0) { | ||
pipeline.push({ | ||
$match: _buildWhere(options.group_fields, options.conditions_of_group) | ||
}); | ||
} | ||
pipeline.push({ | ||
$group: { | ||
_id: null, | ||
count: { | ||
$sum: 1 | ||
} | ||
} | ||
return callback(null, count); | ||
}; | ||
})(this)); | ||
}); | ||
return this._collection(model).aggregate(pipeline, (function(_this) { | ||
return function(error, result) { | ||
if (error) { | ||
return callback(MongoDBAdapter.wrapError('unknown error', error)); | ||
} | ||
if ((result != null ? result.length : void 0) !== 1) { | ||
return callback(new Error('unknown error')); | ||
} | ||
return callback(null, result[0].count); | ||
}; | ||
})(this)); | ||
} else { | ||
return this._collection(model).count(conditions, (function(_this) { | ||
return function(error, count) { | ||
if (error) { | ||
return callback(MongoDBAdapter.wrapError('unknown error', error)); | ||
} | ||
return callback(null, count); | ||
}; | ||
})(this)); | ||
} | ||
}; | ||
@@ -815,0 +902,0 @@ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -331,2 +331,34 @@ var MySQLAdapter, SQLAdapterBase, _, _propertyToSQL, _typeToSQL, e, mysql, types, | ||
MySQLAdapter.prototype.upsert = function(model, data, conditions, options, callback) { | ||
var condition, fields, insert_data, j, key, len, places, ref, sql, tableName, value, values; | ||
tableName = this._connection.models[model].tableName; | ||
insert_data = {}; | ||
for (key in data) { | ||
value = data[key]; | ||
if (value != null ? value.$inc : void 0) { | ||
insert_data[key] = value.$inc; | ||
} else { | ||
insert_data[key] = value; | ||
} | ||
} | ||
for (j = 0, len = conditions.length; j < len; j++) { | ||
condition = conditions[j]; | ||
for (key in condition) { | ||
value = condition[key]; | ||
insert_data[key] = value; | ||
} | ||
} | ||
values = []; | ||
ref = this._buildUpdateSet(model, insert_data, values, true), fields = ref[0], places = ref[1]; | ||
sql = "INSERT INTO `" + tableName + "` (" + fields + ") VALUES (" + places + ")"; | ||
fields = this._buildPartialUpdateSet(model, data, values)[0]; | ||
sql += " ON DUPLICATE KEY UPDATE " + fields; | ||
return this._query(sql, values, function(error, result) { | ||
if (error) { | ||
return _processSaveError(error, callback); | ||
} | ||
return callback(null); | ||
}); | ||
}; | ||
MySQLAdapter.prototype.findById = function(model, id, options, callback) { | ||
@@ -453,3 +485,3 @@ var select, sql, tableName; | ||
MySQLAdapter.prototype.count = function(model, conditions, callback) { | ||
MySQLAdapter.prototype.count = function(model, conditions, options, callback) { | ||
var params, sql, tableName; | ||
@@ -467,2 +499,14 @@ params = []; | ||
} | ||
if (options.group_by) { | ||
sql += ' GROUP BY ' + options.group_by.join(','); | ||
if (options.conditions_of_group.length > 0) { | ||
try { | ||
sql += ' HAVING ' + this._buildWhere(options.group_fields, options.conditions_of_group, params); | ||
} catch (_error) { | ||
e = _error; | ||
return callback(e); | ||
} | ||
} | ||
sql = "SELECT COUNT(*) AS count FROM (" + sql + ") _sub"; | ||
} | ||
return this._query(sql, params, (function(_this) { | ||
@@ -474,3 +518,3 @@ return function(error, result) { | ||
if ((result != null ? result.length : void 0) !== 1) { | ||
return callback(error('unknown error')); | ||
return callback(new Error('unknown error')); | ||
} | ||
@@ -477,0 +521,0 @@ return callback(null, Number(result[0].count)); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -80,2 +80,4 @@ var PostgreSQLAdapter, SQLAdapterBase, _, _propertyToSQL, _typeToSQL, async, e, pg, types, | ||
PostgreSQLAdapter.prototype._regexp_op = '~*'; | ||
function PostgreSQLAdapter(connection) { | ||
@@ -493,3 +495,3 @@ this._connection = connection; | ||
PostgreSQLAdapter.prototype.count = function(model, conditions, callback) { | ||
PostgreSQLAdapter.prototype.count = function(model, conditions, options, callback) { | ||
var params, sql, tableName; | ||
@@ -507,2 +509,14 @@ params = []; | ||
} | ||
if (options.group_by) { | ||
sql += ' GROUP BY ' + options.group_by.join(','); | ||
if (options.conditions_of_group.length > 0) { | ||
try { | ||
sql += ' HAVING ' + this._buildWhere(options.group_fields, options.conditions_of_group, params); | ||
} catch (_error) { | ||
e = _error; | ||
return callback(e); | ||
} | ||
} | ||
sql = "SELECT COUNT(*) AS count FROM (" + sql + ") _sub"; | ||
} | ||
return this._query(sql, params, (function(_this) { | ||
@@ -516,3 +530,3 @@ return function(error, result) { | ||
if ((rows != null ? rows.length : void 0) !== 1) { | ||
return callback(error('unknown error')); | ||
return callback(new Error('unknown error')); | ||
} | ||
@@ -519,0 +533,0 @@ return callback(null, Number(rows[0].count)); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var AdapterBase, RedisAdapter, _, async, error, redis, tableize, types, |
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
var AdapterBase, SQLAdapterBase, types, | ||
var AdapterBase, SQLAdapterBase, _, types, | ||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
@@ -11,2 +11,4 @@ hasProp = {}.hasOwnProperty; | ||
_ = require('lodash'); | ||
SQLAdapterBase = (function(superClass) { | ||
@@ -25,2 +27,4 @@ extend(SQLAdapterBase, superClass); | ||
SQLAdapterBase.prototype._regexp_op = 'REGEXP'; | ||
SQLAdapterBase.prototype._false_value = 'FALSE'; | ||
@@ -131,2 +135,8 @@ | ||
} | ||
} else if (_.isRegExp(value)) { | ||
if (!this._regexp_op) { | ||
throw new Error('regular expression is not supported'); | ||
} | ||
op = ' ' + this._regexp_op + ' '; | ||
value = value.source; | ||
} else if (value === null) { | ||
@@ -248,2 +258,43 @@ return column + " IS NULL"; | ||
SQLAdapterBase.prototype.upsert = function(model, data, conditions, options, callback) { | ||
return this.updatePartial(model, data, conditions, options, (function(_this) { | ||
return function(error, count) { | ||
var condition, i, insert_data, key, len, value; | ||
if (error) { | ||
return callback(error); | ||
} | ||
if (count > 0) { | ||
return callback(null); | ||
} | ||
insert_data = {}; | ||
for (key in data) { | ||
value = data[key]; | ||
if (value != null ? value.$inc : void 0) { | ||
insert_data[key] = value.$inc; | ||
} else { | ||
insert_data[key] = value; | ||
} | ||
} | ||
for (i = 0, len = conditions.length; i < len; i++) { | ||
condition = conditions[i]; | ||
for (key in condition) { | ||
value = condition[key]; | ||
insert_data[key] = value; | ||
} | ||
} | ||
return _this.create(model, insert_data, function(error) { | ||
if (!error) { | ||
return callback(null); | ||
} | ||
if (!/duplicated/.test(error.message)) { | ||
return callback(error); | ||
} | ||
return _this.updatePartial(model, data, conditions, options, function(error, count) { | ||
return callback(error); | ||
}); | ||
}); | ||
}; | ||
})(this)); | ||
}; | ||
return SQLAdapterBase; | ||
@@ -250,0 +301,0 @@ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var SQLite3Adapter_createAdapter; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -68,2 +68,4 @@ var SQLAdapterBase, SQLite3Adapter, _, _propertyToSQL, _typeToSQL, async, e, sqlite3, types, | ||
SQLite3Adapter.prototype._regexp_op = null; | ||
SQLite3Adapter.prototype._false_value = '0'; | ||
@@ -425,3 +427,3 @@ | ||
SQLite3Adapter.prototype.count = function(model, conditions, callback) { | ||
SQLite3Adapter.prototype.count = function(model, conditions, options, callback) { | ||
var params, sql, tableName; | ||
@@ -439,2 +441,14 @@ params = []; | ||
} | ||
if (options.group_by) { | ||
sql += ' GROUP BY ' + options.group_by.join(','); | ||
if (options.conditions_of_group.length > 0) { | ||
try { | ||
sql += ' HAVING ' + this._buildWhere(options.group_fields, options.conditions_of_group, params); | ||
} catch (_error) { | ||
e = _error; | ||
return callback(e); | ||
} | ||
} | ||
sql = "SELECT COUNT(*) AS count FROM (" + sql + ")"; | ||
} | ||
return this._query('all', sql, params, (function(_this) { | ||
@@ -446,3 +460,3 @@ return function(error, result) { | ||
if ((result != null ? result.length : void 0) !== 1) { | ||
return callback(error('unknown error')); | ||
return callback(new Error('unknown error')); | ||
} | ||
@@ -449,0 +463,0 @@ return callback(null, Number(result[0].count)); |
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
var CommandConsole, commander, cormo_console, resolve; | ||
var CommandConsole, commander, cormo_console, net, resolve; | ||
@@ -11,2 +11,4 @@ commander = require('commander'); | ||
net = require('net'); | ||
CommandConsole = (function() { | ||
@@ -17,3 +19,3 @@ function CommandConsole(argv) { | ||
program = new commander.Command('cormo'); | ||
program.usage('console [options]').option('-l, --load <path>', 'load specified module').option('-d, --inspect-depth <depth>', 'specify depth for util.inspect').option('--javascript', 'using JavaScript instead of CoffeeScript').on('load', function(path) { | ||
program.usage('console [options]').option('-l, --load <path>', 'load specified module').option('-d, --inspect-depth <depth>', 'specify depth for util.inspect').option('-s, --serve <port>', 'serve console at port').option('--javascript', 'using JavaScript instead of CoffeeScript').on('load', function(path) { | ||
return loads.push(path); | ||
@@ -24,2 +26,6 @@ }).on('inspect-depth', (function(_this) { | ||
}; | ||
})(this)).on('serve', (function(_this) { | ||
return function(port) { | ||
return _this.serve_port = port; | ||
}; | ||
})(this)).on('javascript', (function(_this) { | ||
@@ -67,2 +73,15 @@ return function() { | ||
CommandConsole.prototype.startCoffee = function() { | ||
var server; | ||
if (this.serve_port) { | ||
server = net.createServer((function(_this) { | ||
return function(socket) { | ||
return cormo_console.startCoffee({ | ||
inspect_depth: _this.inspect_depth, | ||
socket: socket | ||
}).on('exit', function() { | ||
return socket.end(); | ||
}); | ||
}; | ||
})(this)).listen(this.serve_port); | ||
} | ||
return cormo_console.startCoffee({ | ||
@@ -76,2 +95,15 @@ inspect_depth: this.inspect_depth | ||
CommandConsole.prototype.startJS = function() { | ||
var server; | ||
if (this.serve_port) { | ||
server = net.createServer((function(_this) { | ||
return function(socket) { | ||
return cormo_console.startJS({ | ||
inspect_depth: _this.inspect_depth, | ||
socket: socket | ||
}).on('exit', function() { | ||
return socket.end(); | ||
}); | ||
}; | ||
})(this)).listen(this.serve_port); | ||
} | ||
return cormo_console.startJS({ | ||
@@ -78,0 +110,0 @@ inspect_depth: this.inspect_depth |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var Command, path; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var CommandRemoteConsole, net; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var ConnectionAssociation, Promise, _, bindDomain, inflector, types; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -40,8 +40,12 @@ var Connection, EventEmitter, Model, Promise, Toposort, _, _use, bindDomain, inspect, redis, | ||
this._adapter = Promise.promisifyAll(require(__dirname + '/../adapters/' + adapter_name)(this)); | ||
this._promise_connection = this._adapter.connectAsync(settings).then(function() { | ||
return this.connected = true; | ||
})["catch"](function(error) { | ||
this._adapter = null; | ||
return Promise.reject(error); | ||
}); | ||
this._promise_connection = this._adapter.connectAsync(settings).then((function(_this) { | ||
return function() { | ||
return _this.connected = true; | ||
}; | ||
})(this))["catch"]((function(_this) { | ||
return function(error) { | ||
_this._adapter = null; | ||
return Promise.reject(error); | ||
}; | ||
})(this)); | ||
Object.defineProperty(this, 'adapter', { | ||
@@ -67,2 +71,3 @@ get: function() { | ||
Connection.prototype._checkSchemaApplied = function() { | ||
this._initializeModels(); | ||
if (!this._applying_schemas && !this._schema_changed) { | ||
@@ -74,10 +79,21 @@ return Promise.resolve(); | ||
Connection.prototype._initializeModels = function() { | ||
var model, modelClass, ref; | ||
ref = this.models; | ||
for (model in ref) { | ||
modelClass = ref[model]; | ||
if (modelClass.initialize && !modelClass._initialize_called) { | ||
modelClass.initialize(); | ||
modelClass._initializeModels = true; | ||
} | ||
} | ||
}; | ||
Connection.prototype._checkArchive = function() { | ||
var _Archive, model, modelClass, ref, results; | ||
var _Archive, model, modelClass, ref; | ||
ref = this.models; | ||
results = []; | ||
for (model in ref) { | ||
modelClass = ref[model]; | ||
if (modelClass.archive && !modelClass._connection.models.hasOwnProperty('_Archive')) { | ||
results.push(_Archive = (function(superClass1) { | ||
_Archive = (function(superClass1) { | ||
extend(_Archive, superClass1); | ||
@@ -99,8 +115,5 @@ | ||
})(Model)); | ||
} else { | ||
results.push(void 0); | ||
})(Model); | ||
} | ||
} | ||
return results; | ||
}; | ||
@@ -143,2 +156,3 @@ | ||
return function() { | ||
_this._initializeModels(); | ||
if (!_this._schema_changed) { | ||
@@ -145,0 +159,0 @@ return; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var ConnectionManipulate, Promise, bindDomain, inflector, types; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ exports.Connection = require('./connection'); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var ModelCache, Promise, bindDomain, tableize; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var ModelCallback; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -127,2 +127,3 @@ var ColumnProperty, Model, Promise, _, _pf_get, _pf_getChanged, _pf_getPrevious, _pf_isDirty, _pf_reset, _pf_set, _use, tableize, types, util, | ||
Model._checkReady = function() { | ||
this._checkConnection(); | ||
return Promise.all([this._connection._checkSchemaApplied(), this._connection._promise_connection]); | ||
@@ -129,0 +130,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var ModelPersistence, Promise, _, inflector, util; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var ModelQuery, Query, bindDomain; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var ModelTimestamp; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var ModelValidate, Promise, types, util; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -376,3 +376,3 @@ var Promise, Query, _, bindDomain; | ||
} | ||
return _this._adapter.countAsync(_this._name, _this._conditions); | ||
return _this._adapter.countAsync(_this._name, _this._conditions, _this._options); | ||
}; | ||
@@ -441,2 +441,28 @@ })(this)).nodeify(bindDomain(callback)); | ||
Query.prototype.upsert = function(updates, callback) { | ||
return this._model._checkReady().then((function(_this) { | ||
return function() { | ||
var data, errors; | ||
errors = []; | ||
data = {}; | ||
_this._validateAndBuildSaveData(errors, data, updates, '', updates); | ||
if (errors.length > 0) { | ||
return Promise.reject(new Error(errors.join(','))); | ||
} | ||
if (_this._id || _this._find_single_id) { | ||
_this._conditions.push({ | ||
id: _this._id | ||
}); | ||
delete _this._id; | ||
} | ||
_this._connection.log(_this._name, 'upsert', { | ||
data: data, | ||
conditions: _this._conditions, | ||
options: _this._options | ||
}); | ||
return _this._adapter.upsertAsync(_this._name, data, _this._conditions, _this._options); | ||
}; | ||
})(this)).nodeify(bindDomain(callback)); | ||
}; | ||
Query.prototype._doIntegrityActions = function(integrities, ids) { | ||
@@ -443,0 +469,0 @@ var promises; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -13,2 +13,10 @@ var CormoTypesBoolean, CormoTypesDate, CormoTypesGeoPoint, CormoTypesInteger, CormoTypesNumber, CormoTypesObject, CormoTypesRecordID, CormoTypesString, GeoPoint, Integer, RecordID; | ||
CormoTypesString.prototype.toString = function() { | ||
if (this.length) { | ||
return "string(" + this.length + ")"; | ||
} else { | ||
return 'string'; | ||
} | ||
}; | ||
return CormoTypesString; | ||
@@ -21,2 +29,6 @@ | ||
CormoTypesNumber.prototype.toString = function() { | ||
return 'number'; | ||
}; | ||
return CormoTypesNumber; | ||
@@ -29,2 +41,6 @@ | ||
CormoTypesBoolean.prototype.toString = function() { | ||
return 'boolean'; | ||
}; | ||
return CormoTypesBoolean; | ||
@@ -37,2 +53,6 @@ | ||
CormoTypesInteger.prototype.toString = function() { | ||
return 'integer'; | ||
}; | ||
return CormoTypesInteger; | ||
@@ -45,2 +65,6 @@ | ||
CormoTypesGeoPoint.prototype.toString = function() { | ||
return 'geopoint'; | ||
}; | ||
return CormoTypesGeoPoint; | ||
@@ -53,2 +77,6 @@ | ||
CormoTypesDate.prototype.toString = function() { | ||
return 'date'; | ||
}; | ||
return CormoTypesDate; | ||
@@ -61,2 +89,6 @@ | ||
CormoTypesObject.prototype.toString = function() { | ||
return 'object'; | ||
}; | ||
return CormoTypesObject; | ||
@@ -69,2 +101,6 @@ | ||
CormoTypesRecordID.prototype.toString = function() { | ||
return 'recordid'; | ||
}; | ||
return CormoTypesRecordID; | ||
@@ -71,0 +107,0 @@ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -118,2 +118,3 @@ var Connection, Model, Promise, addArgCompleterCoffee, addArgCompleterJS, addHistoryJS, coffee, evalCoffee, evalJS, fs, getCommandId, path, prettyErrorMessage, repl_coffee, repl_js, setupContext, util, vm; | ||
} | ||
this.rli.pause(); | ||
return Promise["try"](function() { | ||
@@ -129,3 +130,3 @@ var defer, js, result; | ||
}); | ||
result = vm.runInThisContext(js, filename); | ||
result = vm.runInContext(js, context, filename); | ||
if (defer) { | ||
@@ -137,10 +138,16 @@ delete context.$; | ||
} | ||
}).then(function(result) { | ||
if (assign_to) { | ||
context[assign_to] = result; | ||
} | ||
return callback(null, result); | ||
})["catch"](function(error) { | ||
return callback(prettyErrorMessage(error, filename, cmd, true)); | ||
}); | ||
}).then((function(_this) { | ||
return function(result) { | ||
if (assign_to) { | ||
context[assign_to] = result; | ||
} | ||
_this.rli.resume(); | ||
return callback(null, result); | ||
}; | ||
})(this))["catch"]((function(_this) { | ||
return function(error) { | ||
_this.rli.resume(); | ||
return callback(prettyErrorMessage(error, filename, cmd, true)); | ||
}; | ||
})(this)); | ||
}; | ||
@@ -166,4 +173,3 @@ | ||
}, | ||
terminal: true, | ||
useGlobal: true | ||
terminal: true | ||
}); | ||
@@ -229,15 +235,21 @@ addArgCompleterCoffee(repl_server); | ||
} | ||
return originalEval(cmd, context, filename, function(error, result) { | ||
if (error) { | ||
return callback(error); | ||
} | ||
return Promise.resolve(result).then(function(result) { | ||
if (assign_to) { | ||
context[assign_to] = result; | ||
this.rli.pause(); | ||
return originalEval(cmd, context, filename, (function(_this) { | ||
return function(error, result) { | ||
if (error) { | ||
_this.rli.resume(); | ||
return callback(error); | ||
} | ||
return callback(null, result); | ||
})["catch"](function(error) { | ||
return callback(error); | ||
}); | ||
}); | ||
return Promise.resolve(result).then(function(result) { | ||
if (assign_to) { | ||
context[assign_to] = result; | ||
} | ||
_this.rli.resume(); | ||
return callback(null, result); | ||
})["catch"](function(error) { | ||
_this.rli.resume(); | ||
return callback(error); | ||
}); | ||
}; | ||
})(this)); | ||
}; | ||
@@ -297,4 +309,3 @@ }; | ||
}, | ||
terminal: true, | ||
useGlobal: true | ||
terminal: true | ||
}); | ||
@@ -301,0 +312,0 @@ repl_server["eval"] = evalJS(repl_server["eval"]); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var Promise; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var inflect; |
{ | ||
"name": "cormo", | ||
"description": "ORM framework for Node.js", | ||
"version": "0.8.12", | ||
"version": "0.8.13", | ||
"keywords": [ | ||
@@ -34,7 +34,7 @@ "orm", | ||
"dependencies": { | ||
"async": "^0.9.0", | ||
"bluebird": "^2.9.15", | ||
"commander": "^2.7.1", | ||
"async": "^1.2.1", | ||
"bluebird": "^2.9.30", | ||
"commander": "^2.8.1", | ||
"inflect": "^0.3.0", | ||
"lodash": "^3.6.0", | ||
"lodash": "^3.9.3", | ||
"toposort-class": "^0.3.1" | ||
@@ -44,14 +44,14 @@ }, | ||
"benchmark": "^1.0.0", | ||
"chai": "^2.1.2", | ||
"coffee-coverage": "^0.4.5", | ||
"coffee-script": "^1.9.1", | ||
"crojsdoc": "^0.8.12", | ||
"microtime": "^1.2.0", | ||
"mocha": "^2.2.1", | ||
"mongodb": "^2.0.25", | ||
"mysql": "^2.6.1", | ||
"pg": "^4.3.0", | ||
"chai": "^3.0.0", | ||
"coffee-coverage": "^0.6.0", | ||
"coffee-script": "^1.9.3", | ||
"crojsdoc": "^0.8.13", | ||
"microtime": "^1.4.2", | ||
"mocha": "^2.2.5", | ||
"mongodb": "^2.0.33", | ||
"mysql": "^2.7.0", | ||
"pg": "^4.4.0", | ||
"redis": "^0.12.1", | ||
"sqlite3": "^3.0.5" | ||
"sqlite3": "^3.0.8" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
284227
55
6441
2
+ Addedasync@1.5.2(transitive)
- Removedasync@0.9.2(transitive)
Updatedasync@^1.2.1
Updatedbluebird@^2.9.30
Updatedcommander@^2.8.1
Updatedlodash@^3.9.3