const mongoose = require('mongoose/browser'); <% unless datatype.downcase == 'component' || datatype.downcase == 'facilitylocation' %> <% unless datatype.downcase == 'id' %>const { IdSchema } = require('./Id');<% end %> 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'); const Any = require('./basetypes/Any'); const { ComponentSchema } = require('./attributes/Component'); const { FacilityLocationSchema } = require('./attributes/FacilityLocation'); <% else %> const Code = require('../basetypes/Code'); const Interval = require('../basetypes/Interval'); const Quantity = require('../basetypes/Quantity'); const DateTime = require('../basetypes/DateTime'); const Any = require('../basetypes/Any'); <% end %> const [Number, String] = [ mongoose.Schema.Types.Number, mongoose.Schema.Types.String, ]; const <%= datatype -%>Schema = <% unless datatype == 'Component' || datatype == 'FacilityLocation' %>DataElementSchema<% else %>new mongoose.Schema<%- end %>({ <%- for attribute in attrs_with_extras -%> <% if attribute[:default] %><%= attribute[:name] %>: { type: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>, default: '<%= attribute[:default] %>' },<% else %><%= attribute[:name] %>: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>,<%- end %> <%- end %> }); module.exports.<%= datatype %>Schema = <%= datatype %>Schema; class <%= datatype %> extends mongoose.Document { constructor(object) { super(object, <%= datatype %>Schema); this._type = 'QDM::<%= datatype %>'; } } module.exports.<%= datatype %> = <%= datatype %>;