summaryrefslogtreecommitdiff
path: root/app/node_modules/okdb/index.js
diff options
context:
space:
mode:
authorSean Fridman <fridman@mail.sfsu.edu>2015-04-10 23:09:05 -0400
committerSean Fridman <fridman@mail.sfsu.edu>2015-04-11 01:38:43 -0400
commit4021d7846ce164f3f0c3cb37d3a1d82d2de489d9 (patch)
tree5b8f998b8e34b581039bc0ed3c871624c25e15e7 /app/node_modules/okdb/index.js
parent1eff07c9c2ca5b61a28a1037a586d25c3791d67b (diff)
Give views sorted resources
Diffstat (limited to 'app/node_modules/okdb/index.js')
-rw-r--r--app/node_modules/okdb/index.js11
1 files changed, 11 insertions, 0 deletions
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)