91 lines
1.6 KiB
Plaintext
Executable File

'use strict';
/**
* <%= filename %> controller
*
* @description: A set of functions called "actions" for managing `<%= globalID %>`.
*/
module.exports = {
/**
* Retrieve <%= id %> records.
*
* @return {Object|Array}
*/
find: async (ctx) => {
return strapi.services.<%= id %>.fetchAll(ctx.query);
},
/**
* Retrieve a <%= id %> record.
*
* @return {Object}
*/
findOne: async (ctx) => {
return strapi.services.<%= id %>.fetch(ctx.params);
},
/**
* Create a/an <%= id %> record.
*
* @return {Object}
*/
create: async (ctx) => {
return strapi.services.<%= id %>.add(ctx.request.body);
},
/**
* Update a/an <%= id %> record.
*
* @return {Object}
*/
update: async (ctx, next) => {
return strapi.services.<%= id %>.edit(ctx.params, ctx.request.body) ;
},
/**
* Destroy a/an <%= id %> record.
*
* @return {Object}
*/
destroy: async (ctx, next) => {
return strapi.services.<%= id %>.remove(ctx.params);
},
/**
* Add relation to a/an <%= id %> record.
*
* @return {Object}
*/
createRelation: async (ctx, next) => {
return strapi.services.<%= id %>.addRelation(ctx.params, ctx.request.body);
},
/**
* Update relation to a/an <%= id %> record.
*
* @return {Object}
*/
updateRelation: async (ctx, next) => {
return strapi.services.<%= id %>.editRelation(ctx.params, ctx.request.body);
},
/**
* Destroy relation to a/an <%= id %> record.
*
* @return {Object}
*/
destroyRelation: async (ctx, next) => {
return strapi.services.<%= id %>.removeRelation(ctx.params, ctx.request.body);
}
};