UNPKG

api-writer

Version:

Streamline API writing with lightning-fast performance. Simplify complex tasks and reduce development time with streamlined code. Boost productivity and efficiency with optimized workflows.

15 lines (11 loc) 429 B
function generateModel(moduleName, properties) { const modelContent = ` const mongoose = require('mongoose'); const ${moduleName}Schema = new mongoose.Schema({ ${properties.map(prop => ` ${prop}: { type: String, required: true },`).join('\n')} }); module.exports = mongoose.model('${moduleName}', ${moduleName}Schema); `; return modelContent; } module.exports = generateModel;