mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 03:44:29 +03:00
a7b0029471
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
36 lines
981 B
JavaScript
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)
|
|
};
|