Sha256: 0d09a9c345b90d6fe9f6397798b1b466b6c4dd5a165b19cecefa043379e80d76

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

const mongoose = require('mongoose');
const { DataElementSchema } = require('./basetypes/DataElement');
const Code = require('./basetypes/Code');
const Interval = require('./basetypes/Interval');
const Quantity = require('./basetypes/Quantity');
const DateTime = require('./basetypes/DateTime');
<% unless datatype.downcase.include? 'component' %>const { ComponentSchema } = require('./Component');<% end %>
<% unless datatype.downcase.include? 'facilitylocation' %>const { FacilityLocationSchema } = require('./FacilityLocation');<% end %>
const Any = require('./basetypes/Any');

const [Number, String] = [
  mongoose.Schema.Types.Number,
  mongoose.Schema.Types.String,
];
<% unless datatype == 'Component' || datatype == 'FacilityLocation' %>
const <%= datatype -%>Schema = DataElementSchema({
  <%- for attribute in attrs_with_extras -%>
  <%= attribute[:name] %>: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>,
  <%- end %>
});
<% else %>
const <%= datatype -%>Schema = new mongoose.Schema({
  <%- for attribute in attrs_with_extras -%>
  <%= attribute[:name] %>: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>,
  <%- end %>
});
<% end %>
module.exports.<%= datatype %>Schema = <%= datatype %>Schema;
module.exports.<%= datatype %> = mongoose.model('<%= datatype %>', <%= datatype %>Schema);

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cqm-models-0.8.3 templates/mongoose_template.js.erb
cqm-models-0.8.2 templates/mongoose_template.js.erb
cqm-models-0.8.1 templates/mongoose_template.js.erb