mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Moved setId
function to Bookshelf events
plugin
no issue - `setId` is only used within the `events` plugin and it makes sense to keep code together - we don't lose anything by putting it here, but it should make it easier to test in the future
This commit is contained in:
parent
5b66933981
commit
0830bcb74e
2 changed files with 9 additions and 9 deletions
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
// All other parts of Ghost, including the frontend & admin UI are only allowed to access data via the API.
|
// All other parts of Ghost, including the frontend & admin UI are only allowed to access data via the API.
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
const ObjectId = require('bson-objectid');
|
|
||||||
const schema = require('../../data/schema');
|
const schema = require('../../data/schema');
|
||||||
|
|
||||||
const ghostBookshelf = require('./bookshelf');
|
const ghostBookshelf = require('./bookshelf');
|
||||||
|
@ -51,14 +50,6 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({
|
||||||
return moment(this.get(attr)).diff(moment(this.previous(attr))) !== 0;
|
return moment(this.get(attr)).diff(moment(this.previous(attr))) !== 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* we auto generate a GUID for each resource
|
|
||||||
* no auto increment
|
|
||||||
*/
|
|
||||||
setId: function setId() {
|
|
||||||
this.set('id', ObjectId().toHexString());
|
|
||||||
},
|
|
||||||
|
|
||||||
wasChanged() {
|
wasChanged() {
|
||||||
/**
|
/**
|
||||||
* @NOTE:
|
* @NOTE:
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const debug = require('@tryghost/debug')('models:base:model-events');
|
const debug = require('@tryghost/debug')('models:base:model-events');
|
||||||
|
const ObjectId = require('bson-objectid');
|
||||||
|
|
||||||
const events = require('../../../lib/common/events');
|
const events = require('../../../lib/common/events');
|
||||||
const schema = require('../../../data/schema');
|
const schema = require('../../../data/schema');
|
||||||
|
@ -31,6 +32,14 @@ module.exports = function (Bookshelf) {
|
||||||
this.on('saved', this.onSaved);
|
this.on('saved', this.onSaved);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* we auto generate a GUID for each resource
|
||||||
|
* no auto increment
|
||||||
|
*/
|
||||||
|
setId: function setId() {
|
||||||
|
this.set('id', ObjectId().toHexString());
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NOTE
|
* @NOTE
|
||||||
* We have to remember the `_previousAttributes` attributes, because when destroying resources
|
* We have to remember the `_previousAttributes` attributes, because when destroying resources
|
||||||
|
|
Loading…
Add table
Reference in a new issue