Sha256: 2f1be7a973e3d45aba46c3aa4112830e4550625559876541c8047d0e117a184e

Contents?: true

Size: 1.7 KB

Versions: 3

Compression:

Stored size: 1.7 KB

Contents

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 %>;

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cqm-models-2.0.1 templates/mongoose_template.js.erb
cqm-models-2.0.0 templates/mongoose_template.js.erb
cqm-models-1.1.1.0 templates/mongoose_template.js.erb