78 lines
1.4 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 <%= humanizeId %> entries.
2016-03-18 11:12:50 +01:00
*
* @return {Object|Array}
*/
find: function * () {
try {
this.body = yield strapi.services.<%= humanizeId %>.fetchAll(this.query);
2016-03-18 11:12:50 +01:00
} catch (err) {
this.body = err;
}
},
/**
* Get a specific <%= humanizeId %>.
2016-03-18 11:12:50 +01:00
*
* @return {Object|Array}
*/
findOne: function * () {
try {
this.body = yield strapi.services.<%= humanizeId %>.fetch(this.params)
2016-03-18 11:12:50 +01:00
} catch (err) {
this.body = err;
}
},
/**
* Create a/an <%= humanizeId %> entry.
2016-03-18 11:12:50 +01:00
*
* @return {Object}
*/
create: function * () {
try {
this.body = yield strapi.services.<%= humanizeId %>.add(this.request.body);
2016-03-18 11:12:50 +01:00
} catch (err) {
this.body = err;
}
},
/**
* Update a/an <%= humanizeId %> entry.
2016-03-18 11:12:50 +01:00
*
* @return {Object}
*/
update: function * () {
try {
this.body = yield strapi.services.<%= humanizeId %>.edit(this.params, this.request.body) ;
2016-03-18 11:12:50 +01:00
} catch (err) {
this.body = err;
}
},
/**
* Destroy a/an <%= humanizeId %> entry.
2016-03-18 11:12:50 +01:00
*
* @return {Object}
*/
destroy: function * () {
try {
this.body = yield strapi.services.<%= humanizeId %>.remove(this.params);
2016-03-18 11:12:50 +01:00
} catch (err) {
this.body = err;
}
}
};