91 lines
1.6 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) => {
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
},
/**
* 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
},
/**
* Add relation to a/an <%= id %> record.
2016-03-18 11:12:50 +01:00
*
* @return {Object}
*/
createRelation: async (ctx, next) => {
return strapi.services.<%= id %>.addRelation(ctx.params, ctx.request.body);
2016-03-18 11:12:50 +01:00
},
/**
* Update relation to a/an <%= id %> record.
*
* @return {Object}
*/
updateRelation: async (ctx, next) => {
return strapi.services.<%= id %>.editRelation(ctx.params, ctx.request.body);
},
2016-03-18 11:12:50 +01:00
/**
* Destroy relation to a/an <%= id %> record.
2016-03-18 11:12:50 +01:00
*
* @return {Object}
*/
destroyRelation: async (ctx, next) => {
return strapi.services.<%= id %>.removeRelation(ctx.params, ctx.request.body);
2016-03-18 11:12:50 +01:00
}
};