UNPKG

fastify-mongoose-rest

Version:

Rest API generator tools for fastify and mongoose

37 lines 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InsertMany = void 0; const utils_1 = require("../utils"); function InsertMany(basePath, model, options) { const { tags, validationSchema } = options; let response = {}; let body = { type: 'array' }; if (validationSchema) { body = { type: 'array', items: { type: 'object', properties: { ...validationSchema, }, }, }; response = (0, utils_1.createResponseSchema)(validationSchema, 'array'); } return { method: 'POST', url: `${basePath}/insert-many`, schema: { summary: `Create multiple new ${model.modelName} resources`, tags, body, response, }, handler: async (request, reply) => { const resources = await model.insertMany(request.body); return reply.send(resources); }, }; } exports.InsertMany = InsertMany; //# sourceMappingURL=insert-many.js.map