src/back/models/Entity.js
function isDirty(attribute) {
    expect(arguments).to.have.length.below(
      2,
      'Invalid arguments length when checking if an Entity attribute is ' +
      'dirty (it has to be passed less than 2 arguments)'
    );

    var attributes = this.Entity.attributes;

    if (attribute) {
      expect(attribute).to.be.a(
        'string',
        'Invalid argument "attribute" when checking if an Entity attribute ' +
        'is dirty (it has to be a string)'
      );

      expect(attributes).to.have.ownProperty(
        attribute,
        'Invalid argument "attribute" when checking an Entity attribute ' +
        'is dirty (this attribute does not exist in the Entity)'
      );

      var newAttributes = {};
      newAttributes[attribute] = attributes[attribute];
      attributes = newAttributes;
    }

    if (this.isNew) {
      return true;
    }

    for (var attributeName in attributes) {
      if (_cleanSet) {
        if (_attributeIsSet[attributeName]) {
          if (
            !_attributeStorageValues.hasOwnProperty(attributeName) ||
            _attributeStorageValues[attributeName] !== this[attributeName]
          ) {
            return true;
          }
        }
      } else {
        if (
          !_attributeStorageValues.hasOwnProperty(attributeName) ||
          _attributeStorageValues[attributeName] !== this[attributeName]
        ) {
          return true;
        }
      }
    }

    return false;
  }
function isDirty(attribute) {
    expect(arguments).to.have.length.below(
      2,
      'Invalid arguments length when checking if an Entity attribute is ' +
      'dirty (it has to be passed less than 2 arguments)'
    );

    var attributes = this.Entity.attributes;

    if (attribute) {
      expect(attribute).to.be.a(
        'string',
        'Invalid argument "attribute" when checking if an Entity attribute ' +
        'is dirty (it has to be a string)'
      );

      expect(attributes).to.have.ownProperty(
        attribute,
        'Invalid argument "attribute" when checking an Entity attribute ' +
        'is dirty (this attribute does not exist in the Entity)'
      );

      var newAttributes = {};
      newAttributes[attribute] = attributes[attribute];
      attributes = newAttributes;
    }

    if (this.isNew) {
      return true;
    }

    for (var attributeName in attributes) {
      if (_cleanSet) {
        if (_attributeIsSet[attributeName]) {
          if (
            !_attributeStorageValues.hasOwnProperty(attributeName) ||
            _attributeStorageValues[attributeName] !== this[attributeName]
          ) {
            return true;
          }
        }
      } else {
        if (
          !_attributeStorageValues.hasOwnProperty(attributeName) ||
          _attributeStorageValues[attributeName] !== this[attributeName]
        ) {
          return true;
        }
      }
    }

    return false;
  }
function isDirty ( attribute ) { expect ( arguments ) . to . have . length . below ( 2 , 'Invalid arguments length when checking if an Entity attribute is ' + 'dirty (it has to be passed less than 2 arguments)' ) ; var attributes = this . Entity . attributes ; if ( attribute ) { expect ( attribute ) . to . be . a ( 'string' , 'Invalid argument "attribute" when checking if an Entity attribute ' + 'is dirty (it has to be a string)' ) ; expect ( attributes ) . to . have . ownProperty ( attribute , 'Invalid argument "attribute" when checking an Entity attribute ' + 'is dirty (this attribute does not exist in the Entity)' ) ; var newAttributes = { } ; newAttributes [ attribute ] = attributes [ attribute ] ; attributes = newAttributes ; } if ( this . isNew ) { return true ; } for ( var attributeName in attributes ) { if ( _cleanSet ) { if ( _attributeIsSet [ attributeName ] ) { if ( ! _attributeStorageValues . hasOwnProperty ( attributeName ) || _attributeStorageValues [ attributeName ] !== this [ attributeName ] ) { return true ; } } } else { if ( ! _attributeStorageValues . hasOwnProperty ( attributeName ) || _attributeStorageValues [ attributeName ] !== this [ attributeName ] ) { return true ; } } } return false ; }
Checks if an Entity attribute is dirty.
@name module:back4app-entity/models.Entity#isDirty
@function
@param {?string} [attribute] The name of the attribute to be checked. If no
attribute is passed, all attributes will be checked.
@returns {boolean} True if is dirty and false otherwise.
@example
console.log(myEntity.isDirty('myAttribute')); // Validates attribute
// "myAttribute" of
// Entity "myEntity"
@example
console.log(myEntity.isDirty()); // Checks all attributes of "myEntity"
Checks if an Entity attribute is dirty .