summaryrefslogtreecommitdiff
path: root/lib/db/index.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-07-07 18:43:24 +0200
committerJules Laplace <julescarbon@gmail.com>2017-07-07 18:43:24 +0200
commitb89147ecd38b0f95a2e4917aba7f44bf3bb70327 (patch)
tree554d0d726755c89e55dbe79f0339cceb13543dd5 /lib/db/index.js
parentd520c67839724e80d8b68b8fe933f1e7755a8f42 (diff)
refactor audioplayer
Diffstat (limited to 'lib/db/index.js')
-rw-r--r--lib/db/index.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/db/index.js b/lib/db/index.js
index 2e63f74..1c7cc15 100644
--- a/lib/db/index.js
+++ b/lib/db/index.js
@@ -13,7 +13,7 @@ var File = db.File = bookshelf.Model.extend({
hasTimestamps: true,
})
var Job = db.Job = bookshelf.Model.extend({
- tableName: 'job',
+ tableName: 'jobs',
hasTimestamps: true,
})
var Task = db.Task = bookshelf.Model.extend({
@@ -37,12 +37,19 @@ db.crud = function(model) {
qb.orderBy("id", "desc")
if (limit) qb.limit( limit )
if (offset) qb.offset( offset )
+ // console.log(qb)
return qb
}).fetchAll()
},
show: (id) => {
return new model({'id': id}).fetch()
},
+ show_ids: (ids) => {
+ return model.query( (qb) => {
+ qb.whereIn('id', ids)
+ return qb
+ }).fetchAll()
+ },
create: (data) => {
return new model(data).save()
},
@@ -54,3 +61,16 @@ db.crud = function(model) {
},
}
}
+
+function memoize (f) {
+ const o = {}
+ return (model) => {
+ console.log(model)
+ t = model.toString()
+ if (o[t]) {
+ return o[t]
+ }
+ o[t] = f(model)
+ return o[t]
+ }
+} \ No newline at end of file