78 lines
1.3 KiB
Plaintext
Raw Normal View History

2016-03-18 11:12:50 +01:00
'use strict';
/**
* A set of functions called "actions" for `<%= globalID %>`
*/
module.exports = {
/**
* Get <%= id %> entries.
*
* @return {Object|Array}
*/
find: function * () {
try {
this.body = yield strapi.services.<%= id %>.fetchAll(this.query);
} catch (err) {
this.body = err;
}
},
/**
* Get a specific <%= id %>.
*
* @return {Object|Array}
*/
findOne: function * () {
try {
this.body = yield strapi.services.<%= id %>.fetch(this.params)
} catch (err) {
this.body = err;
}
},
/**
* Create a/an <%= id %> entry.
*
* @return {Object}
*/
create: function * () {
try {
this.body = yield strapi.services.<%= id %>.add(this.request.body);
} catch (err) {
this.body = err;
}
},
/**
* Update a/an <%= id %> entry.
*
* @return {Object}
*/
update: function * () {
try {
this.body = yield strapi.services.<%= id %>.edit(this.params, this.request.body) ;
} catch (err) {
this.body = err;
}
},
/**
* Destroy a/an <%= id %> entry.
*
* @return {Object}
*/
destroy: function * () {
try {
this.body = yield strapi.services.<%= id %>.remove(this.params);
} catch (err) {
this.body = err;
}
}
};