mirror of
https://github.com/strapi/strapi.git
synced 2025-07-17 05:53:01 +00:00
78 lines
1.3 KiB
Plaintext
78 lines
1.3 KiB
Plaintext
![]() |
'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;
|
||
|
}
|
||
|
}
|
||
|
};
|