From 4021d7846ce164f3f0c3cb37d3a1d82d2de489d9 Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Fri, 10 Apr 2015 23:09:05 -0400 Subject: Give views sorted resources --- app/node_modules/okdb/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/node_modules/okdb/index.js') diff --git a/app/node_modules/okdb/index.js b/app/node_modules/okdb/index.js index 7639ec6..c00087c 100644 --- a/app/node_modules/okdb/index.js +++ b/app/node_modules/okdb/index.js @@ -117,6 +117,17 @@ FSDB.prototype.remove = function(collection, id) { } }; +FSDB.prototype.sortBy = function(collection, prop, descend) { + var schema = this._schemas[collection]; + if (!schema) + return resolve(null, new Error('No such collection type')); + if (!prop) + return resolve(null, new Error('Bad input')); + + var result = this._db(collection).sortByOrder([prop], [!descend]); + return resolve(result); +}; + FSDB.prototype.find = function(collection, id) { var schema = this._schemas[collection]; if (!schema) -- cgit v1.2.3-70-g09d2