Sha256: 64e4ece7ed5fcb162fdefb2aac436616bdb7372376ea8e6886d87b7830684891

Contents?: true

Size: 1.4 KB

Versions: 5

Compression:

Stored size: 1.4 KB

Contents

const mongoose = require('mongoose/browser');

const { IdentifierSchema } = require('./Identifier');
const Code = require('../basetypes/Code');
const Interval = require('../basetypes/Interval');
const Quantity = require('../basetypes/Quantity');
const DateTime = require('../basetypes/DateTime');
const QDMDate = require('../basetypes/QDMDate');
const Any = require('../basetypes/Any');

const [Schema] = [mongoose.Schema];

const [Number, String] = [
  mongoose.Schema.Types.Number,
  mongoose.Schema.Types.String,
];

const EntitySchema = new mongoose.Schema({
  id: String,
  identifier: IdentifierSchema,
  qdmVersion: { type: String, default: '5.6' },
  _type: { type: String, default: 'QDM::Entity' },

});

module.exports.EntitySchema = EntitySchema;
class Entity extends mongoose.Document {
  constructor(object) {
    super(object, EntitySchema);
    this._type = 'QDM::Entity';
  }
}

function EntitySchemaFunction(add, options) {
  const extended = new Schema({
    identifier: IdentifierSchema,
    qdmVersion: { type: String, default: '5.6' },
    _type: { type: String, default: 'QDM::Entity' },


    id: {
      type: String,
      default() {
        return this._id ? this._id.toString() : mongoose.Types.ObjectId().toString();
      },
    },

  }, options);

  if (add) {
    extended.add(add);
  }

  return extended;
}

module.exports.Entity = Entity;
module.exports.EntitySchemaFunction = EntitySchemaFunction;

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cqm-models-4.1.1 app/assets/javascripts/attributes/Entity.js
cqm-models-4.1.0 app/assets/javascripts/attributes/Entity.js
cqm-models-4.0.2 app/assets/javascripts/attributes/Entity.js
cqm-models-4.0.1 app/assets/javascripts/attributes/Entity.js
cqm-models-4.0.0 app/assets/javascripts/attributes/Entity.js