75 lines
1.3 KiB
Plaintext
Raw Normal View History

2016-03-18 11:12:50 +01:00
'use strict';
/**
* <%= filename %> controller
*
* @description: A set of functions called "actions" for managing `<%= globalID %>`.
2016-03-18 11:12:50 +01:00
*/
module.exports = {
2016-03-18 11:12:50 +01:00
/**
* Retrieve <%= id %> records.
2016-03-18 11:12:50 +01:00
*
* @return {Object|Array}
*/
find: async (ctx) => {
2018-07-05 11:28:55 +02:00
if (ctx.query._q) {
return strapi.services.<%= id %>.search(ctx.query);
} else {
return strapi.services.<%= id %>.fetchAll(ctx.query);
}
2016-03-18 11:12:50 +01:00
},
/**
* Retrieve a <%= id %> record.
2016-03-18 11:12:50 +01:00
*
* @return {Object}
2016-03-18 11:12:50 +01:00
*/
findOne: async (ctx) => {
return strapi.services.<%= id %>.fetch(ctx.params);
2016-03-18 11:12:50 +01:00
},
/**
* Count <%= id %> records.
*
* @return {Number}
*/
count: async (ctx) => {
return strapi.services.<%= id %>.count(ctx.query);
},
2016-03-18 11:12:50 +01:00
/**
* Create a/an <%= id %> record.
2016-03-18 11:12:50 +01:00
*
* @return {Object}
*/
create: async (ctx) => {
return strapi.services.<%= id %>.add(ctx.request.body);
2016-03-18 11:12:50 +01:00
},
/**
* Update a/an <%= id %> record.
2016-03-18 11:12:50 +01:00
*
* @return {Object}
*/
update: async (ctx, next) => {
return strapi.services.<%= id %>.edit(ctx.params, ctx.request.body) ;
2016-03-18 11:12:50 +01:00
},
/**
* Destroy a/an <%= id %> record.
2016-03-18 11:12:50 +01:00
*
* @return {Object}
*/
destroy: async (ctx, next) => {
return strapi.services.<%= id %>.remove(ctx.params);
2016-03-18 11:12:50 +01:00
}
};