mirror of
				https://github.com/strapi/strapi.git
				synced 2025-11-04 03:43:34 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			80 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Plaintext
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			80 lines
		
	
	
		
			1.4 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) => {
 | 
						|
    if (!ctx.params._id.match(/^[0-9a-fA-F]{24}$/)) {
 | 
						|
      return ctx.notFound();
 | 
						|
    }
 | 
						|
 | 
						|
    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);
 | 
						|
  }
 | 
						|
};
 |