Comparing version 0.0.19 to 0.0.20
@@ -375,2 +375,6 @@ /** | ||
if (filter.group) { | ||
sql += ' ' + self.buildGroupBy(filter.group); | ||
} | ||
if (filter.limit) { | ||
@@ -752,4 +756,5 @@ sql += ' ' + self.buildLimit(filter.limit, filter.offset || filter.skip || 0); | ||
MySQL.prototype.buildOrderBy = function buildOrderBy(order) { | ||
if (typeof order === 'string') | ||
if (typeof order === 'string') { | ||
order = [order]; | ||
} | ||
return 'ORDER BY ' + order.join(', '); | ||
@@ -762,2 +767,9 @@ }; | ||
MySQL.prototype.buildGroupBy = function buildGroupBy(group) { | ||
if (typeof group === 'string') { | ||
group = [group]; | ||
} | ||
return 'GROUP BY ' + group.join(', '); | ||
}; | ||
function acceptedDefaults(prop) { | ||
@@ -764,0 +776,0 @@ if (/^INT|^BIGINT|^VAR|^TINY/i.test(datatype(prop))) { |
@@ -179,3 +179,7 @@ /** | ||
} | ||
this.query('SELECT ' + this.getColumns(model) + ' FROM ' + this.tableEscaped(model) + ' ' + this.toFilter(model, filter), function(err, data) { | ||
var sql = 'SELECT ' + this.getColumns(model) + ' FROM ' | ||
+ this.tableEscaped(model) + ' ' | ||
+ this.toFilter(model, filter); | ||
this.query(sql, function(err, data) { | ||
if (err) { | ||
@@ -352,2 +356,6 @@ return callback(err, []); | ||
if (filter.group) { | ||
out += self.buildGroupBy(filter.group); | ||
} | ||
if (filter.limit) { | ||
@@ -624,4 +632,4 @@ out += self.buildLimit(filter.limit,(filter.offset || '0')); | ||
val = (typeof val.toISOString === 'function') | ||
? val.toISOString() | ||
: val.toString(); | ||
? val.toISOString() | ||
: val.toString(); | ||
} | ||
@@ -690,4 +698,4 @@ | ||
var cs = [], or = [], | ||
self = adapter, | ||
props = self._models[model].properties; | ||
self = adapter, | ||
props = self._models[model].properties; | ||
@@ -793,4 +801,11 @@ Object.keys(conds).forEach(function(key) { | ||
PG.prototype.buildGroupBy = function buildGroupBy(group) { | ||
if (typeof group === 'string') { | ||
group = [group]; | ||
} | ||
return ' GROUP BY ' + group.join(', '); | ||
}; | ||
function escapeName(name) { | ||
return '"' + name.replace(/\./g, '"."') + '"'; | ||
} |
@@ -13,5 +13,5 @@ /** | ||
exports.initialize = function initializeSchema(schema, callback) { | ||
if (!r) | ||
if (!r) { | ||
return; | ||
} | ||
var s = schema.settings; | ||
@@ -105,5 +105,5 @@ | ||
RethinkDB.prototype.autoupdate = function(cb) { | ||
var _this = this; | ||
var self = this; | ||
_this.pool.acquire(function(error, client) { | ||
self.pool.acquire(function(error, client) { | ||
if (error) { | ||
@@ -113,3 +113,3 @@ throw error; | ||
r.db(_this.database).tableList().run(client, function(error, cursor) { | ||
r.db(self.database).tableList().run(client, function(error, cursor) { | ||
@@ -121,5 +121,5 @@ if (!error) { | ||
} | ||
async.each(Object.keys(_this._models), function(model, cb2) { | ||
async.each(Object.keys(self._models), function(model, cb2) { | ||
if (list.length === 0 || list.indexOf(model) < 0) { | ||
r.db(_this.database).tableCreate(model).run(client, function(error) { | ||
r.db(self.database).tableCreate(model).run(client, function(error) { | ||
if (error) { | ||
@@ -135,5 +135,5 @@ return cb2(error); | ||
function createIndices() { | ||
var properties = _this._models[model].properties; | ||
var properties = self._models[model].properties; | ||
if (Object.keys(properties).length > 0) { | ||
r.db(_this.database).table(model).indexList().run(client, function(error, cursor) { | ||
r.db(self.database).table(model).indexList().run(client, function(error, cursor) { | ||
if (error) { | ||
@@ -147,4 +147,4 @@ return cb2(error); | ||
async.each(Object.keys(properties), function(property, cb3) { | ||
if ((properties[property].index || _this._foreignKeys[model].indexOf(property) >= 0) && list.indexOf(property) < 0) { | ||
r.db(_this.database).table(model).indexCreate(property).run(client, function(error) { | ||
if ((properties[property].index || self._foreignKeys[model].indexOf(property) >= 0) && list.indexOf(property) < 0) { | ||
r.db(self.database).table(model).indexCreate(property).run(client, function(error) { | ||
if (error) | ||
@@ -167,3 +167,3 @@ return cb3(error); | ||
}, function(err) { | ||
_this.pool.release(client); | ||
self.pool.release(client); | ||
cb(err); | ||
@@ -173,3 +173,3 @@ }); | ||
} else { | ||
_this.pool.release(client); | ||
self.pool.release(client); | ||
cb(error); | ||
@@ -188,9 +188,9 @@ } | ||
RethinkDB.prototype.isActual = function(cb) { | ||
var _this = this; | ||
var self = this; | ||
_this.pool.acquire(function(error, client) { | ||
self.pool.acquire(function(error, client) { | ||
if (error) | ||
throw error; | ||
r.db(_this.database).tableList().run(client, function(error, cursor) { | ||
r.db(self.database).tableList().run(client, function(error, cursor) { | ||
if (!error) { | ||
@@ -200,11 +200,11 @@ if (cursor.hasNext()) { | ||
if (error) { | ||
_this.pool.release(client); | ||
self.pool.release(client); | ||
return cb(error); | ||
} | ||
var actual = true; | ||
async.each(Object.keys(_this._models), function(model, cb2) { | ||
async.each(Object.keys(self._models), function(model, cb2) { | ||
if (!actual) | ||
return cb2(); | ||
var properties = _this._models[model].properties; | ||
var properties = self._models[model].properties; | ||
if (list.indexOf(model) < 0) { | ||
@@ -214,3 +214,3 @@ actual = false; | ||
} else { | ||
r.db(_this.database).table(model).indexList().run(client, function(error, cursor) { | ||
r.db(self.database).table(model).indexList().run(client, function(error, cursor) { | ||
if (error) | ||
@@ -224,3 +224,3 @@ return cb2(error); | ||
Object.keys(properties).forEach(function(property) { | ||
if ((properties[property].index || _this._foreignKeys[model].indexOf(property) >= 0) && list.indexOf(property) < 0) | ||
if ((properties[property].index || self._foreignKeys[model].indexOf(property) >= 0) && list.indexOf(property) < 0) | ||
actual = false; | ||
@@ -233,12 +233,12 @@ }); | ||
}, function(err) { | ||
_this.pool.release(client); | ||
self.pool.release(client); | ||
cb(err, actual); | ||
}); | ||
}); | ||
} else if (_this._models.length > 0) { | ||
_this.pool.release(client); | ||
} else if (self._models.length > 0) { | ||
self.pool.release(client); | ||
cb(null, false); | ||
} | ||
} else { | ||
_this.pool.release(client); | ||
self.pool.release(client); | ||
cb(error); | ||
@@ -256,5 +256,5 @@ } | ||
RethinkDB.prototype.create = function(model, data, callback) { | ||
var _this = this; | ||
var self = this; | ||
_this.pool.acquire(function(error, client) { | ||
self.pool.acquire(function(error, client) { | ||
if (error) | ||
@@ -272,4 +272,4 @@ throw error; | ||
}); | ||
r.db(_this.database).table(model).insert(data).run(client, function(err, m) { | ||
_this.pool.release(client); | ||
r.db(self.database).table(model).insert(data).run(client, function(err, m) { | ||
self.pool.release(client); | ||
err = err || m.first_error && new Error(m.first_error); | ||
@@ -285,5 +285,5 @@ if (m.generated_keys) { | ||
RethinkDB.prototype.save = function(model, data, callback) { | ||
var _this = this; | ||
var self = this; | ||
_this.pool.acquire(function(error, client) { | ||
self.pool.acquire(function(error, client) { | ||
if (error) | ||
@@ -298,4 +298,4 @@ throw error; | ||
}); | ||
r.db(_this.database).table(model).insert(data, {upsert: true}).run(client, function(err, notice) { | ||
_this.pool.release(client); | ||
r.db(self.database).table(model).insert(data, {upsert: true}).run(client, function(err, notice) { | ||
self.pool.release(client); | ||
err = err || notice.first_error && new Error(notice.first_error); | ||
@@ -308,10 +308,10 @@ callback(err, notice); | ||
RethinkDB.prototype.exists = function(model, id, callback) { | ||
var _this = this; | ||
var self = this; | ||
_this.pool.acquire(function(error, client) { | ||
self.pool.acquire(function(error, client) { | ||
if (error) | ||
throw error; | ||
r.db(_this.database).table(model).get(id).run(client, function(err, data) { | ||
_this.pool.release(client); | ||
r.db(self.database).table(model).get(id).run(client, function(err, data) { | ||
self.pool.release(client); | ||
callback(err, !!(!err && data)); | ||
@@ -323,18 +323,18 @@ }); | ||
RethinkDB.prototype.findById = function findById(model, id, callback) { | ||
var _this = this; | ||
var self = this; | ||
_this.pool.acquire(function(error, client) { | ||
self.pool.acquire(function(error, client) { | ||
if (error) | ||
throw error; | ||
r.db(_this.database).table(model).get(id).run(client, function(err, data) { | ||
r.db(self.database).table(model).get(id).run(client, function(err, data) { | ||
if (data) | ||
Object.keys(data).forEach(function(key) { | ||
if (_this._models[model].properties[key]['type']['name'] === "Date") | ||
if (self._models[model].properties[key]['type']['name'] === "Date") | ||
data[key] = moment.unix(data[key]).toDate(); | ||
}.bind(_this)); | ||
}.bind(self)); | ||
_this.pool.release(client); | ||
self.pool.release(client); | ||
callback(err, data); | ||
}.bind(_this)); | ||
}.bind(self)); | ||
}); | ||
@@ -344,4 +344,4 @@ }; | ||
RethinkDB.prototype.updateOrCreate = function updateOrCreate(model, data, callback) { | ||
var _this = this; | ||
_this.pool.acquire(function(error, client) { | ||
var self = this; | ||
self.pool.acquire(function(error, client) { | ||
if (error) { | ||
@@ -354,9 +354,11 @@ throw error; | ||
data.forEach(function(value, key) { | ||
if (value instanceof Date) | ||
if (value instanceof Date) { | ||
data[key] = moment(value).unix(); | ||
if (value === undefined) | ||
} | ||
if (value === undefined) { | ||
data[key] = null; | ||
} | ||
}); | ||
r.db(_this.database).table(model).insert(data, {upsert: true}).run(client, function(err, m) { | ||
_this.pool.release(client); | ||
r.db(self.database).table(model).insert(data, {upsert: true}).run(client, function(err, m) { | ||
self.pool.release(client); | ||
err = err || m.first_error && new Error(m.first_error); | ||
@@ -369,10 +371,10 @@ callback(err, err ? null : m['generated_keys'][0]); | ||
RethinkDB.prototype.destroy = function destroy(model, id, callback) { | ||
var _this = this; | ||
var self = this; | ||
_this.pool.acquire(function(error, client) { | ||
self.pool.acquire(function(error, client) { | ||
if (error) | ||
throw error; | ||
r.db(_this.database).table(model).get(id).delete().run(client, function(error, result) { | ||
_this.pool.release(client); | ||
r.db(self.database).table(model).get(id).delete().run(client, function(error, result) { | ||
self.pool.release(client); | ||
callback(error); | ||
@@ -384,5 +386,5 @@ }); | ||
RethinkDB.prototype.remove = function remove(model, filter, callback) { | ||
var _this = this; | ||
var self = this; | ||
_this.pool.acquire(function(error, client) { | ||
self.pool.acquire(function(error, client) { | ||
if (error) | ||
@@ -395,6 +397,6 @@ throw error; | ||
var promise = r.db(_this.database).table(model); | ||
var promise = r.db(self.database).table(model); | ||
if (filter.where) { | ||
promise = _processWhere(_this, model, filter.where, promise); | ||
promise = _processWhere(self, model, filter.where, promise); | ||
} | ||
@@ -411,7 +413,7 @@ | ||
_keys = _this._models[model].properties; | ||
_model = _this._models[model].model; | ||
_keys = self._models[model].properties; | ||
_model = self._models[model].model; | ||
promise.delete().run(client, function(error, cursor) { | ||
_this.pool.release(client); | ||
self.pool.release(client); | ||
callback(error); | ||
@@ -423,5 +425,5 @@ }); | ||
RethinkDB.prototype.all = function all(model, filter, callback) { | ||
var _this = this; | ||
var self = this; | ||
_this.pool.acquire(function(error, client) { | ||
self.pool.acquire(function(error, client) { | ||
if (error) | ||
@@ -434,6 +436,6 @@ throw error; | ||
var promise = r.db(_this.database).table(model); | ||
var promise = r.db(self.database).table(model); | ||
if (filter.where) { | ||
promise = _processWhere(_this, model, filter.where, promise); | ||
promise = _processWhere(self, model, filter.where, promise); | ||
} | ||
@@ -469,8 +471,8 @@ | ||
_keys = _this._models[model].properties; | ||
_model = _this._models[model].model; | ||
_keys = self._models[model].properties; | ||
_model = self._models[model].model; | ||
promise.run(client, function(error, cursor) { | ||
if (error) { | ||
_this.pool.release(client); | ||
self.pool.release(client); | ||
callback(error, null); | ||
@@ -480,3 +482,3 @@ } | ||
if (err) { | ||
_this.pool.release(client); | ||
self.pool.release(client); | ||
return callback(err); | ||
@@ -495,3 +497,3 @@ } | ||
_this.pool.release(client); | ||
self.pool.release(client); | ||
@@ -509,9 +511,9 @@ if (filter && filter.include && filter.include.length > 0) { | ||
RethinkDB.prototype.destroyAll = function destroyAll(model, callback) { | ||
var _this = this; | ||
var self = this; | ||
_this.pool.acquire(function(error, client) { | ||
self.pool.acquire(function(error, client) { | ||
if (error) | ||
throw error; | ||
r.db(_this.database).table(model).delete().run(client, function(error, result) { | ||
_this.pool.release(client); | ||
r.db(self.database).table(model).delete().run(client, function(error, result) { | ||
self.pool.release(client); | ||
callback(error, result); | ||
@@ -523,15 +525,15 @@ }); | ||
RethinkDB.prototype.count = function count(model, callback, where) { | ||
var _this = this; | ||
var self = this; | ||
_this.pool.acquire(function(error, client) { | ||
self.pool.acquire(function(error, client) { | ||
if (error) | ||
throw error; | ||
var promise = r.db(_this.database).table(model); | ||
var promise = r.db(self.database).table(model); | ||
if (where && typeof where === "object") | ||
promise = _processWhere(_this, model, where, promise); | ||
promise = _processWhere(self, model, where, promise); | ||
promise.count().run(client, function(err, count) { | ||
_this.pool.release(client); | ||
self.pool.release(client); | ||
callback(err, count); | ||
@@ -543,5 +545,5 @@ }); | ||
RethinkDB.prototype.updateAttributes = function updateAttrs(model, id, data, cb) { | ||
var _this = this; | ||
var self = this; | ||
_this.pool.acquire(function(error, client) { | ||
self.pool.acquire(function(error, client) { | ||
if (error) | ||
@@ -557,4 +559,4 @@ throw error; | ||
}); | ||
r.db(_this.database).table(model).update(data).run(client, function(err, object) { | ||
_this.pool.release(client); | ||
r.db(self.database).table(model).update(data).run(client, function(err, object) { | ||
self.pool.release(client); | ||
cb(err, data); | ||
@@ -566,9 +568,9 @@ }); | ||
RethinkDB.prototype.disconnect = function() { | ||
var _this = this; | ||
_this.pool.drain(function() { | ||
_this.pool.destroyAllNow(); | ||
var self = this; | ||
self.pool.drain(function() { | ||
self.pool.destroyAllNow(); | ||
}); | ||
}; | ||
function _processWhere(_this, model, where, promise) { | ||
function _processWhere(self, model, where, promise) { | ||
//Transform promise (a rethinkdb query) based on the given where clause. | ||
@@ -592,3 +594,3 @@ //Returns the modified promise | ||
} | ||
var hasIndex = _this._models[model].properties[k].index || _this._foreignKeys[model].indexOf(k) >= 0; | ||
var hasIndex = self._models[model].properties[k].index || self._foreignKeys[model].indexOf(k) >= 0; | ||
for (i = 0, m = allConds.length; i < m; i++) { | ||
@@ -595,0 +597,0 @@ spec = allConds[i][0]; |
@@ -66,6 +66,6 @@ /** | ||
var sql = 'UPDATE ' + this.tableEscaped(model) + ' SET ' + | ||
Object.keys(data).map(function(key) { | ||
queryParams.push(data[key]); | ||
return key + ' = ?'; | ||
}).join(', ') + ' WHERE id = ' + data.id; | ||
Object.keys(data).map(function(key) { | ||
queryParams.push(data[key]); | ||
return key + ' = ?'; | ||
}).join(', ') + ' WHERE id = ' + data.id; | ||
this.command(sql, queryParams, function(err) { | ||
@@ -174,8 +174,8 @@ callback(err); | ||
return 'strftime(' + this.toDatabase(prop, val[0]) + ')' + | ||
' AND strftime(' + | ||
this.toDatabase(prop, val[1]) + ')'; | ||
' AND strftime(' + | ||
this.toDatabase(prop, val[1]) + ')'; | ||
} else { | ||
return this.toDatabase(prop, val[0]) + | ||
' AND ' + | ||
this.toDatabase(prop, val[1]); | ||
' AND ' + | ||
this.toDatabase(prop, val[1]); | ||
} | ||
@@ -278,2 +278,7 @@ } else if (operator === 'in' || operator === 'inq' || operator === 'nin') { | ||
} | ||
if (filter.group) { | ||
sql += ' ' + self.buildGroupBy(filter.group); | ||
} | ||
if (filter.limit) { | ||
@@ -388,3 +393,3 @@ sql += ' ' + this.buildLimit(filter.limit, filter.skip || 0); | ||
if ('undefined' !== typeof m.properties[prop]['index'] | ||
|| 'undefined' !== typeof m.properties[prop]['unique']) { | ||
|| 'undefined' !== typeof m.properties[prop]['unique']) { | ||
var foundKey = false; | ||
@@ -437,3 +442,3 @@ indexes.forEach(function(index) { | ||
if (oldSettings.notnull !== notnull | ||
|| oldSettings.dflt_value !== dflt_value) { | ||
|| oldSettings.dflt_value !== dflt_value) { | ||
return true; | ||
@@ -458,3 +463,3 @@ } | ||
var inSql = 'INSERT INTO `' + model + '` (' + nsst.join(',') + ') ' | ||
+ 'SELECT ' + nsst.join(',') + ' FROM `tmp_' + model + '`;'; | ||
+ 'SELECT ' + nsst.join(',') + ' FROM `tmp_' + model + '`;'; | ||
var dpSql = 'DROP TABLE `tmp_' + model + '`;'; | ||
@@ -488,3 +493,3 @@ return self.command(rbSql, function(err) { | ||
return datatype(p) + ' ' + | ||
(p.allowNull === false || p['null'] === false ? 'NOT NULL' : 'NULL'); | ||
(p.allowNull === false || p['null'] === false ? 'NOT NULL' : 'NULL'); | ||
}; | ||
@@ -516,4 +521,4 @@ | ||
var cs = [], or = [], | ||
self = adapter, | ||
props = self._models[model].properties; | ||
self = adapter, | ||
props = self._models[model].properties; | ||
@@ -620,1 +625,8 @@ Object.keys(conds).forEach(function(key) { | ||
}; | ||
SQLite3.prototype.buildGroupBy = function buildGroupBy(group) { | ||
if (typeof group === 'string') { | ||
group = [group]; | ||
} | ||
return 'GROUP BY ' + group.join(', '); | ||
}; |
@@ -33,3 +33,3 @@ /* | ||
} | ||
['all', 'run', 'exec'].forEach(function(method) { | ||
@@ -46,3 +46,3 @@ self[method] = function(params, callback) { | ||
}); | ||
['find', 'findOne'].forEach(function(method) { | ||
@@ -58,4 +58,4 @@ self[method] = function(params, callback) { | ||
}); | ||
['skip', 'limit', 'order', 'sort'].forEach(function(method) { | ||
['skip', 'limit', 'order', 'sort', 'group'].forEach(function(method) { | ||
self[method] = function(key, value) { | ||
@@ -78,3 +78,3 @@ this.q.pkey = false; | ||
}); | ||
self.asc = function(value) { | ||
@@ -85,3 +85,3 @@ this.q.pkey = false; | ||
}; | ||
self.desc = function(value) { | ||
@@ -92,3 +92,3 @@ this.q.pkey = false; | ||
}; | ||
self.where = function(key, value) { | ||
@@ -103,3 +103,3 @@ if (typeof value === 'undefined') { | ||
}; | ||
self.or = function(values) { | ||
@@ -111,3 +111,3 @@ if (Array.isArray(values)) { | ||
}; | ||
self.range = function(key, from, to) { | ||
@@ -134,3 +134,3 @@ if (typeof to === 'undefined') { | ||
}; | ||
['gt', 'gte', 'lt', 'lte', 'in', 'inq', 'ne', 'neq', 'nin', 'regex', 'like', 'nlike', 'between'].forEach(function(method) { | ||
@@ -155,3 +155,3 @@ self[method] = function(key, value) { | ||
}); | ||
self.slice = function(values) { | ||
@@ -168,3 +168,3 @@ if (Array.isArray(values)) { | ||
}; | ||
/** | ||
@@ -171,0 +171,0 @@ * Destroy records |
@@ -14,4 +14,5 @@ exports.inherits = function(newClass, baseClass) { | ||
} catch (e) { | ||
// console.log(e) | ||
console.log('Run "npm install ' + module + '" command to using ' + module + ' database engine'); | ||
var str = module; | ||
if(module === 'rethinkdb') { str = module + ' generic-pool moment'; } | ||
console.log('Run "npm install ' + str + '" command to using ' + module + ' database engine'); | ||
process.exit(1); | ||
@@ -18,0 +19,0 @@ } |
{ | ||
"name": "caminte", | ||
"description": "ORM for every database: redis, mysql, neo4j, mongodb, rethinkdb, postgres, sqlite, tingodb", | ||
"version": "0.0.19", | ||
"author": "Aleksej Gordejev <aleksej@gordejev.lv> (http://www.gordejev.lv)", | ||
"version": "0.0.20", | ||
"author": { | ||
"name": "Aleksej Gordejev", | ||
"email" : "aleksej@gordejev.lv", | ||
"url": "http://www.gordejev.lv" | ||
}, | ||
"homepage": "http://camintejs.com/", | ||
@@ -51,2 +55,6 @@ "contributors": [ | ||
"email": "" | ||
}, | ||
{ | ||
"name": "Aleksej Gordejev", | ||
"email": "aleksej@gordejev.lv" | ||
} | ||
@@ -106,5 +114,7 @@ ], | ||
"felix-couchdb": ">= 1.0.3", | ||
"cradle": ">= 0.6.3" | ||
"cradle": ">= 0.6.3", | ||
"rethinkdb":">= 1.12.0", | ||
"generic-pool":">= 2.0.4" | ||
}, | ||
"optionalDependencies": {} | ||
} |
@@ -198,2 +198,3 @@ [![Build Status](https://travis-ci.org/biggora/caminte.png?branch=master)](https://travis-ci.org/biggora/caminte) | ||
* [findById](#findbyid) | ||
* [update](#update) | ||
* [updateOrCreate, upsert](#upsert) | ||
@@ -352,3 +353,29 @@ * [count](#count) | ||
``` | ||
<a name="update"></a> | ||
#### #update(params, data, callback) | ||
Update if exists instance | ||
```javascript | ||
User.update({ | ||
where : { | ||
email: 'example@example.com' | ||
} | ||
}, { | ||
active: 0 | ||
}, function(err, user){ | ||
// your code here | ||
}); | ||
// or | ||
Post.update({ | ||
id: { | ||
inq: [100, 101, 102] | ||
} | ||
}, { | ||
tag: 'city' | ||
}, function(err, post){ | ||
// your code here | ||
}); | ||
``` | ||
<a name="count"></a> | ||
@@ -443,2 +470,3 @@ #### #count(params, callback) | ||
* [sort, order](#sort) | ||
* [group](#group) | ||
* [asc](#asc) | ||
@@ -676,2 +704,16 @@ * [desc](#desc) | ||
``` | ||
<a name="group"></a> | ||
#### #group(key) | ||
Sets the group by column. | ||
```javascript | ||
Query.group('title'); | ||
// is the same as | ||
Post.find({ | ||
group: 'title' | ||
}}, function(err, posts){ | ||
// your code here | ||
}); | ||
``` | ||
<a name="asc"></a> | ||
@@ -678,0 +720,0 @@ #### #asc(key) |
Sorry, the diff of this file is not supported yet
621242
11400
960
16