Add count property and DRY

This commit is contained in:
2019-04-13 13:05:47 +02:00
parent f6189bf910
commit 6f97c905d6
4 changed files with 26 additions and 27 deletions

14
lib/contracts/record.js Normal file
View File

@@ -0,0 +1,14 @@
const Base = require('./base');
const paged = require('../utils/pagination');
class Record extends Base {
all(options = {}) {
return this.count
.then((count) => {
let records = paged(count, options).map((id) => this.getById(id));
return Promise.all(records);
});
}
}
module.exports = Record