Ghost/core/server/models/index.js
Fabian Becker 41cef386bc Implements Models & Data API for Apps
closes #2138
- Adds new models for AppField and AppSetting
- Removed permitted attributes from App model (handled by base)
- Added reference from Post to AppFields
- Added fixture data to DataGenerator
- Added integration tests for Apps, AppSettings, AppFields
- Added import for Apps
- Added app_fields to default fixtures
2014-04-16 18:14:56 +02:00

39 lines
1.2 KiB
JavaScript

var migrations = require('../data/migration'),
_ = require('lodash'),
when = require('when');
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,
App: require('./app').App,
AppField: require('./appField').AppField,
AppSetting: require('./appSetting').AppSetting,
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) {
return when.all(_.map(posts.toJSON(), function (post) {
return self.Post.destroy(post.id);
}));
}).then(function () {
return self.Tag.browse().then(function (tags) {
return when.all(_.map(tags.toJSON(), function (tag) {
return self.Tag.destroy(tag.id);
}));
});
});
}
};