Ghost/core/server/models/mobiledoc-revision.js
Katharina Irrgang a7b0029471 Added mobiledoc revisions functionality
closes #9927

- Added post model implementation to be able to store up to 10 versions of mobiledoc
- Bumped GQL to support filtering on the mobiledoc revision table
- Added tests ensuring new functionality works
2018-10-09 15:31:09 +02:00

36 lines
981 B
JavaScript

const ghostBookshelf = require('./base');
const MobiledocRevision = ghostBookshelf.Model.extend({
tableName: 'mobiledoc_revisions'
}, {
permittedOptions(methodName) {
let options = ghostBookshelf.Model.permittedOptions.call(this, methodName);
const validOptions = {
findAll: ['filter', 'columns']
};
if (validOptions[methodName]) {
options = options.concat(validOptions[methodName]);
}
return options;
},
orderDefaultRaw() {
return 'created_at_ts DESC';
},
toJSON(unfilteredOptions) {
const options = MobiledocRevision.filterOptions(unfilteredOptions, 'toJSON');
const attrs = ghostBookshelf.Model.prototype.toJSON.call(this, options);
// CASE: only for internal accuracy
delete attrs.created_at_ts;
return attrs;
}
});
module.exports = {
MobiledocRevision: ghostBookshelf.model('MobiledocRevision', MobiledocRevision)
};