ForestAdmin/toolbelt

View on GitHub
src/services/dumpers/templates/agent-nodejs/javascript/models/model.hbs

Summary

Maintainability
Test Coverage
const Mongoose = require('mongoose');

const schema = new Mongoose.Schema({
{{#each fields as |field|}}
  {{wsc field.name}}: {{#if field.ref}}{ type: {{field.type}}, ref: '{{field.ref}}' }{{else if (isObject field.type)}}{{>renderNested type=field.type level=1}}{{else}}{{field.type}}{{/if}},
{{/each}}
}, {
  timestamps: {{timestamps}},
});

module.exports = {
  collectionName: '{{collectionName}}',
  modelName: '{{modelName}}',
  schema,
};