0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-13 22:41:32 -05:00
ghost/core/server/models/index.js

35 lines
1 KiB
JavaScript
Raw Normal View History

var migrations = require('../data/migration'),
2014-02-05 00:40:30 -08:00
_ = require('lodash');
2013-06-01 10:47:41 -04:00
module.exports = {
Post: require('./post').Post,
User: require('./user').User,
Role: require('./role').Role,
Permission: require('./permission').Permission,
Settings: require('./settings').Settings,
Tag: require('./tag').Tag,
Base: require('./base'),
Session: require('./session').Session,
init: function () {
return migrations.init();
},
// ### deleteAllContent
// Delete all content from the database (posts, tags, tags_posts)
deleteAllContent: function () {
var self = this;
return self.Post.browse().then(function (posts) {
_.each(posts.toJSON(), function (post) {
self.Post.destroy(post.id);
});
}).then(function () {
self.Tag.browse().then(function (tags) {
_.each(tags.toJSON(), function (tag) {
self.Tag.destroy(tag.id);
});
});
});
}
};