2013-12-25 04:05:20 +04:00
|
|
|
var migrations = require('../data/migration'),
|
2014-02-05 12:40:30 +04:00
|
|
|
_ = require('lodash');
|
2013-06-01 18:47:41 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
module.exports = {
|
|
|
|
Post: require('./post').Post,
|
|
|
|
User: require('./user').User,
|
|
|
|
Role: require('./role').Role,
|
|
|
|
Permission: require('./permission').Permission,
|
|
|
|
Settings: require('./settings').Settings,
|
2013-08-21 16:55:58 +04:00
|
|
|
Tag: require('./tag').Tag,
|
2013-11-21 00:36:02 +04:00
|
|
|
Base: require('./base'),
|
2013-11-24 18:29:36 +04:00
|
|
|
Session: require('./session').Session,
|
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
init: function () {
|
2013-07-27 23:41:10 +04:00
|
|
|
return migrations.init();
|
2013-08-03 19:11:16 +04:00
|
|
|
},
|
|
|
|
reset: function () {
|
|
|
|
return migrations.reset().then(function () {
|
|
|
|
return migrations.init();
|
|
|
|
});
|
2013-08-26 23:44:19 +04:00
|
|
|
},
|
2013-12-25 04:05:20 +04:00
|
|
|
// ### 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);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2013-06-25 15:43:15 +04:00
|
|
|
}
|
|
|
|
};
|