2013-11-24 18:29:36 +04:00
|
|
|
var ghostBookshelf = require('./base'),
|
2014-02-19 17:57:26 +04:00
|
|
|
|
2013-11-24 18:29:36 +04:00
|
|
|
Session,
|
|
|
|
Sessions;
|
|
|
|
|
|
|
|
Session = ghostBookshelf.Model.extend({
|
|
|
|
|
2014-04-03 17:03:09 +04:00
|
|
|
tableName: 'sessions',
|
|
|
|
|
|
|
|
// override for base function since we don't have
|
|
|
|
// a created_by field for sessions
|
|
|
|
creating: function (newObj, attr, options) {
|
|
|
|
/*jshint unused:false*/
|
|
|
|
},
|
|
|
|
|
|
|
|
// override for base function since we don't have
|
|
|
|
// a updated_by field for sessions
|
|
|
|
saving: function (newObj, attr, options) {
|
|
|
|
/*jshint unused:false*/
|
|
|
|
// Remove any properties which don't belong on the model
|
|
|
|
this.attributes = this.pick(this.permittedAttributes());
|
|
|
|
},
|
2013-11-24 18:29:36 +04:00
|
|
|
|
|
|
|
}, {
|
|
|
|
destroyAll: function (options) {
|
|
|
|
options = options || {};
|
2014-02-27 06:44:09 +04:00
|
|
|
return ghostBookshelf.Collection.forge([], {model: this}).fetch()
|
|
|
|
.then(function (collection) {
|
2013-11-24 18:29:36 +04:00
|
|
|
collection.invokeThen('destroy', options);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Sessions = ghostBookshelf.Collection.extend({
|
|
|
|
model: Session
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
Session: Session,
|
|
|
|
Sessions: Sessions
|
2014-02-27 06:44:09 +04:00
|
|
|
};
|