2013-12-25 04:05:20 +04:00
|
|
|
var migrations = require('../data/migration'),
|
2014-03-24 17:49:23 +04:00
|
|
|
_ = require('lodash'),
|
|
|
|
when = require('when');
|
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,
|
2014-02-12 07:40:39 +04:00
|
|
|
App: require('./app').App,
|
2014-02-25 00:28:18 +04:00
|
|
|
AppField: require('./appField').AppField,
|
|
|
|
AppSetting: require('./appSetting').AppSetting,
|
2013-11-24 18:29:36 +04:00
|
|
|
|
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
|
|
|
},
|
2013-12-25 04:05:20 +04:00
|
|
|
// ### deleteAllContent
|
|
|
|
// Delete all content from the database (posts, tags, tags_posts)
|
|
|
|
deleteAllContent: function () {
|
|
|
|
var self = this;
|
|
|
|
|
Consistency in model method naming
- The API has the BREAD naming for methods
- The model now has findAll, findOne, findPage (where needed), edit, add and destroy, meaning it is similar but with a bit more flexibility
- browse, read, update, create, and delete, which were effectively just aliases, have all been removed.
- added jsDoc for the model methods
2014-05-05 19:18:38 +04:00
|
|
|
return self.Post.findAll().then(function (posts) {
|
2014-03-24 17:49:23 +04:00
|
|
|
return when.all(_.map(posts.toJSON(), function (post) {
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 16:41:19 +04:00
|
|
|
return self.Post.destroy({id: post.id});
|
2014-03-24 17:49:23 +04:00
|
|
|
}));
|
2013-12-25 04:05:20 +04:00
|
|
|
}).then(function () {
|
Consistency in model method naming
- The API has the BREAD naming for methods
- The model now has findAll, findOne, findPage (where needed), edit, add and destroy, meaning it is similar but with a bit more flexibility
- browse, read, update, create, and delete, which were effectively just aliases, have all been removed.
- added jsDoc for the model methods
2014-05-05 19:18:38 +04:00
|
|
|
return self.Tag.findAll().then(function (tags) {
|
2014-03-24 17:49:23 +04:00
|
|
|
return when.all(_.map(tags.toJSON(), function (tag) {
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 16:41:19 +04:00
|
|
|
return self.Tag.destroy({id: tag.id});
|
2014-03-24 17:49:23 +04:00
|
|
|
}));
|
2013-12-25 04:05:20 +04:00
|
|
|
});
|
|
|
|
});
|
2013-06-25 15:43:15 +04:00
|
|
|
}
|
|
|
|
};
|