diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-07-07 18:43:24 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-07-07 18:43:24 +0200 |
| commit | b89147ecd38b0f95a2e4917aba7f44bf3bb70327 (patch) | |
| tree | 554d0d726755c89e55dbe79f0339cceb13543dd5 /lib/db | |
| parent | d520c67839724e80d8b68b8fe933f1e7755a8f42 (diff) | |
refactor audioplayer
Diffstat (limited to 'lib/db')
| -rw-r--r-- | lib/db/index.js | 22 |
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 |
