src/back/MongoAdapter.js
function loadEntityAttribute(Entity, attribute) {
    expect(arguments).to.have.length(
      2,
      'Invalid arguments length when loading an entity attribute in a ' +
      'MongoAdapter (it has to be passed 2 arguments)'
    );

    expect(Entity).to.be.a(
      'function',
      'Invalid argument "Entity" when loading an entity in a ' +
      'MongoAdapter (it has to be an Entity class)'
    );

    expect(classes.isGeneral(entity.models.Entity, Entity)).to.be.equal(
      true,
      'Invalid argument "Entity" when loading an entity attribute in a ' +
      'MongoAdapter (it has to be an Entity class)'
    );

    expect(attribute).to.be.an.instanceOf(
      Attribute,
      'Invalid argument "attribute" when loading an entity attribute in a ' +
      'MongoAdapter (it has to be an Attribute instance)'
    );

    var dataName = attribute.getDataName(Entity.adapterName);

    expect(dataName).to.not.match(
      /^\$/,
      'The dataName of an Attribute cannot start with "$" in a MongoAdapter'
    );

    expect(dataName).to.not.contain(
      '.',
      'The dataName of an Attribute cannot contain "." in a MongoAdapter'
    );

    expect(dataName).to.not.contain(
      '\0',
      'The dataName of an Attribute cannot contain "\0" in a MongoAdapter'
    );

    expect(dataName).to.not.equal(
      'Entity',
      'The dataName of an Attribute cannot be equal to "Entity" in a ' +
      'MongoAdapter'
    );

    expect(dataName).to.not.equal(
      '_id',
      'The dataName of an Attribute cannot be equal to "_id" in a MongoAdapter'
    );

    expect(_collections).to.have.ownProperty(
      Entity.dataName,
      'Failed to load the attribute in an Entity called "' +
      Entity.specification.name + '" because the Entity was not loaded yet'
    );

    expect(_collections[Entity.dataName]).to.not.contain(
      dataName,
      'Failed to load the attribute "' + attribute.name + '" in an Entity ' +
      'called "' + Entity.specification.name + '" because it is not ' +
      'possible to have attributes of the same Entity with duplicated ' +
      'dataName in a MongoAdapter'
    );

    _collections[Entity.dataName].push(dataName);
  }
function loadEntityAttribute(Entity, attribute) {
    expect(arguments).to.have.length(
      2,
      'Invalid arguments length when loading an entity attribute in a ' +
      'MongoAdapter (it has to be passed 2 arguments)'
    );

    expect(Entity).to.be.a(
      'function',
      'Invalid argument "Entity" when loading an entity in a ' +
      'MongoAdapter (it has to be an Entity class)'
    );

    expect(classes.isGeneral(entity.models.Entity, Entity)).to.be.equal(
      true,
      'Invalid argument "Entity" when loading an entity attribute in a ' +
      'MongoAdapter (it has to be an Entity class)'
    );

    expect(attribute).to.be.an.instanceOf(
      Attribute,
      'Invalid argument "attribute" when loading an entity attribute in a ' +
      'MongoAdapter (it has to be an Attribute instance)'
    );

    var dataName = attribute.getDataName(Entity.adapterName);

    expect(dataName).to.not.match(
      /^\$/,
      'The dataName of an Attribute cannot start with "$" in a MongoAdapter'
    );

    expect(dataName).to.not.contain(
      '.',
      'The dataName of an Attribute cannot contain "." in a MongoAdapter'
    );

    expect(dataName).to.not.contain(
      '\0',
      'The dataName of an Attribute cannot contain "\0" in a MongoAdapter'
    );

    expect(dataName).to.not.equal(
      'Entity',
      'The dataName of an Attribute cannot be equal to "Entity" in a ' +
      'MongoAdapter'
    );

    expect(dataName).to.not.equal(
      '_id',
      'The dataName of an Attribute cannot be equal to "_id" in a MongoAdapter'
    );

    expect(_collections).to.have.ownProperty(
      Entity.dataName,
      'Failed to load the attribute in an Entity called "' +
      Entity.specification.name + '" because the Entity was not loaded yet'
    );

    expect(_collections[Entity.dataName]).to.not.contain(
      dataName,
      'Failed to load the attribute "' + attribute.name + '" in an Entity ' +
      'called "' + Entity.specification.name + '" because it is not ' +
      'possible to have attributes of the same Entity with duplicated ' +
      'dataName in a MongoAdapter'
    );

    _collections[Entity.dataName].push(dataName);
  }
function loadEntityAttribute ( Entity , attribute ) { expect ( arguments ) . to . have . length ( 2 , 'Invalid arguments length when loading an entity attribute in a ' + 'MongoAdapter (it has to be passed 2 arguments)' ) ; expect ( Entity ) . to . be . a ( 'function' , 'Invalid argument "Entity" when loading an entity in a ' + 'MongoAdapter (it has to be an Entity class)' ) ; expect ( classes . isGeneral ( entity . models . Entity , Entity ) ) . to . be . equal ( true , 'Invalid argument "Entity" when loading an entity attribute in a ' + 'MongoAdapter (it has to be an Entity class)' ) ; expect ( attribute ) . to . be . an . instanceOf ( Attribute , 'Invalid argument "attribute" when loading an entity attribute in a ' + 'MongoAdapter (it has to be an Attribute instance)' ) ; var dataName = attribute . getDataName ( Entity . adapterName ) ; expect ( dataName ) . to . not . match ( / ^\$ / , 'The dataName of an Attribute cannot start with "$" in a MongoAdapter' ) ; expect ( dataName ) . to . not . contain ( '.' , 'The dataName of an Attribute cannot contain "." in a MongoAdapter' ) ; expect ( dataName ) . to . not . contain ( '\0' , 'The dataName of an Attribute cannot contain "\0" in a MongoAdapter' ) ; expect ( dataName ) . to . not . equal ( 'Entity' , 'The dataName of an Attribute cannot be equal to "Entity" in a ' + 'MongoAdapter' ) ; expect ( dataName ) . to . not . equal ( '_id' , 'The dataName of an Attribute cannot be equal to "_id" in a MongoAdapter' ) ; expect ( _collections ) . to . have . ownProperty ( Entity . dataName , 'Failed to load the attribute in an Entity called "' + Entity . specification . name + '" because the Entity was not loaded yet' ) ; expect ( _collections [ Entity . dataName ] ) . to . not . contain ( dataName , 'Failed to load the attribute "' + attribute . name + '" in an Entity ' + 'called "' + Entity . specification . name + '" because it is not ' + 'possible to have attributes of the same Entity with duplicated ' + 'dataName in a MongoAdapter' ) ; _collections [ Entity . dataName ] . push ( dataName ) ; }
Registers the Attribute on the Entity on Collection Dictionary, if valid.
@name module:back4app-entity-mongodb.MongoAdapter#loadEntityAttribute
@function
@param {!module:back4app-entity/models/Entity} Entity The Entity Class
to have attribute validated and added to Entity on Collection dictionary.
@param {!module:back4app-entity/models/attributes.Attribute} attribute
The Attribute to be validated and added to Entity.
@example
_Entity.adapter.loadEntityAttribute(_Entity, attribute);
Registers the Attribute on the Entity on Collection Dictionary if valid .