mirror of
https://github.com/strapi/strapi.git
synced 2025-07-23 17:10:08 +00:00
76 lines
1.3 KiB
Plaintext
Executable File
76 lines
1.3 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) => {
|
|
const data = await strapi.services.<%= id %>.fetchAll(ctx.query);
|
|
|
|
// Send 200 `ok`
|
|
ctx.send(data);
|
|
},
|
|
|
|
/**
|
|
* Retrieve a <%= id %> record.
|
|
*
|
|
* @return {Object}
|
|
*/
|
|
|
|
findOne: async (ctx) => {
|
|
const data = await strapi.services.<%= id %>.fetch(ctx.params);
|
|
|
|
// Send 200 `ok`
|
|
ctx.send(data);
|
|
},
|
|
|
|
/**
|
|
* Create a/an <%= id %> record.
|
|
*
|
|
* @return {Object}
|
|
*/
|
|
|
|
create: async (ctx) => {
|
|
const data = await strapi.services.<%= id %>.add(ctx.request.body);
|
|
|
|
// Send 201 `created`
|
|
ctx.created(data);
|
|
},
|
|
|
|
/**
|
|
* Update a/an <%= id %> record.
|
|
*
|
|
* @return {Object}
|
|
*/
|
|
|
|
update: async (ctx, next) => {
|
|
const data = await strapi.services.<%= id %>.edit(ctx.params, ctx.request.body) ;
|
|
|
|
// Send 200 `ok`
|
|
ctx.send(data);
|
|
},
|
|
|
|
/**
|
|
* Destroy a/an <%= id %> record.
|
|
*
|
|
* @return {Object}
|
|
*/
|
|
|
|
destroy: async (ctx, next) => {
|
|
const data = await strapi.services.<%= id %>.remove(ctx.params);
|
|
|
|
// Send 200 `ok`
|
|
ctx.send(data);
|
|
}
|
|
};
|