2016-03-18 11:12:50 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
2017-01-11 18:24:26 +01:00
|
|
|
* <%= filename %> controller
|
|
|
|
*
|
|
|
|
* @description: A set of functions called "actions" for managing `<%= globalID %>`.
|
2016-03-18 11:12:50 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
module.exports = {
|
2017-01-11 18:24:26 +01:00
|
|
|
|
2016-03-18 11:12:50 +01:00
|
|
|
/**
|
2017-02-14 01:10:37 +01:00
|
|
|
* Retrieve <%= id %> records.
|
2016-03-18 11:12:50 +01:00
|
|
|
*
|
|
|
|
* @return {Object|Array}
|
|
|
|
*/
|
|
|
|
|
2017-01-11 18:24:26 +01:00
|
|
|
find: async (ctx) => {
|
2017-02-14 01:10:37 +01:00
|
|
|
const data = await strapi.services.<%= id %>.fetchAll(ctx.query);
|
2017-01-11 18:24:26 +01:00
|
|
|
|
|
|
|
// Send 200 `ok`
|
|
|
|
ctx.send(data);
|
2016-03-18 11:12:50 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2017-02-14 01:10:37 +01:00
|
|
|
* Retrieve a <%= id %> record.
|
2016-03-18 11:12:50 +01:00
|
|
|
*
|
2017-01-11 18:24:26 +01:00
|
|
|
* @return {Object}
|
2016-03-18 11:12:50 +01:00
|
|
|
*/
|
|
|
|
|
2017-01-11 18:24:26 +01:00
|
|
|
findOne: async (ctx) => {
|
2017-02-14 01:10:37 +01:00
|
|
|
const data = await strapi.services.<%= id %>.fetch(ctx.params);
|
2017-01-11 18:24:26 +01:00
|
|
|
|
|
|
|
// Send 200 `ok`
|
|
|
|
ctx.send(data);
|
2016-03-18 11:12:50 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2017-02-14 01:10:37 +01:00
|
|
|
* Create a/an <%= id %> record.
|
2016-03-18 11:12:50 +01:00
|
|
|
*
|
|
|
|
* @return {Object}
|
|
|
|
*/
|
|
|
|
|
2017-01-11 18:24:26 +01:00
|
|
|
create: async (ctx) => {
|
2017-02-14 01:10:37 +01:00
|
|
|
const data = await strapi.services.<%= id %>.add(ctx.request.body);
|
2017-01-11 18:24:26 +01:00
|
|
|
|
|
|
|
// Send 201 `created`
|
|
|
|
ctx.created(data);
|
2016-03-18 11:12:50 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2017-02-14 01:10:37 +01:00
|
|
|
* Update a/an <%= id %> record.
|
2016-03-18 11:12:50 +01:00
|
|
|
*
|
|
|
|
* @return {Object}
|
|
|
|
*/
|
|
|
|
|
2016-11-28 11:34:05 +01:00
|
|
|
update: async (ctx, next) => {
|
2017-02-14 01:10:37 +01:00
|
|
|
const data = await strapi.services.<%= id %>.edit(ctx.params, ctx.request.body) ;
|
2017-01-11 18:24:26 +01:00
|
|
|
|
|
|
|
// Send 200 `ok`
|
|
|
|
ctx.send(data);
|
2016-03-18 11:12:50 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2017-02-14 01:10:37 +01:00
|
|
|
* Destroy a/an <%= id %> record.
|
2016-03-18 11:12:50 +01:00
|
|
|
*
|
|
|
|
* @return {Object}
|
|
|
|
*/
|
|
|
|
|
2016-11-28 11:34:05 +01:00
|
|
|
destroy: async (ctx, next) => {
|
2017-02-14 01:10:37 +01:00
|
|
|
const data = await strapi.services.<%= id %>.remove(ctx.params);
|
2017-01-11 18:24:26 +01:00
|
|
|
|
|
|
|
// Send 200 `ok`
|
|
|
|
ctx.send(data);
|
2016-03-18 11:12:50 +01:00
|
|
|
}
|
|
|
|
};
|