Sha256: d38d24977ff7a478a05f2f08fdfdb52a93d638e2036ff13f914c767647916cbe

Contents?: true

Size: 1.4 KB

Versions: 10

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.5' },
  _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.5' },
    _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

10 entries across 10 versions & 1 rubygems

Version Path
cqm-models-3.1.2 app/assets/javascripts/attributes/Entity.js
cqm-models-3.1.1 app/assets/javascripts/attributes/Entity.js
cqm-models-3.1.0 app/assets/javascripts/attributes/Entity.js
cqm-models-3.0.6 app/assets/javascripts/attributes/Entity.js
cqm-models-3.0.5 app/assets/javascripts/attributes/Entity.js
cqm-models-3.0.4 app/assets/javascripts/attributes/Entity.js
cqm-models-3.0.3 app/assets/javascripts/attributes/Entity.js
cqm-models-3.0.2 app/assets/javascripts/attributes/Entity.js
cqm-models-3.0.1 app/assets/javascripts/attributes/Entity.js
cqm-models-3.0.0 app/assets/javascripts/attributes/Entity.js