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