Class: Entity

Entity~ Entity

Class represents a single Entity (i.e. a record) which is a collection of Properties with current values. Usage: Setting data options: - entity.users__last_name = 'Smith'; - entity.setValue('users__last_name', 'Smith'); - entity.setValues({ users__last_name: 'Smith', }); Getting data options: - entity.data; // Gets all property values as single JSON object - entity.users__last_name; - entity.getPropertySubmitValue('users__last_name');

new Entity(schema, rawData)

Parameters:
Name Type Description
schema Schema Schema object
rawData object Raw data object. Keys are Property names, Values are Property values.
Source:
Entity.js
Fires:
  • .'change', 'reset', 'save', 'delete',event: 'destroy']

Extends

  • EventEmitter

Members


createId

Generates a new unique id and assigns it to this entity. If the idProperty is of type 'uuid', then it generates a new UUID. If not, then it generates a temp id.
Source:
Entity.js

loadOriginalData

Manually load originalData into this Entity, *after* the entity has already been created. This resets the Entity, so it's 'as new'. This is mainly for updating Entity with new data from remote storage medium. Assumes (and sets) isPersisted === true.
Source:
Entity.js

reset

Resets the Entity to a state as if it had just been created, all based on _originalData.
Source:
Entity.js

hasProperty

Checks to see if a property exists
Source:
Entity.js

getSchema

Gets the Schema object
Source:
Entity.js

prop

Alias for this.properties
Source:
Entity.js

getProperty

Gets a single Property by name,
Source:
Entity.js

getPropertySubmitValue

Gets the "submit" value of one Property,
Source:
Entity.js

getPropertyDisplayValue

Gets the "display" value of one Property,
Source:
Entity.js

getSubmitValues

Gets an object of properties/values for this Entity, Values are the "submit" values, not the "raw" or "parsed" or "display" values.
Source:
Entity.js

submitValues

Gets "submit" values for this Entity.
Source:
Entity.js

getDisplayValues

Gets an object of values for this Entity, Values are the "display" values, not the "raw" or "parsed" or "submit" values.
Source:
Entity.js

displayValues

Gets "display" values for this Entity.
Source:
Entity.js

getRawValues

Gets an object of values for this Entity, Values are the "raw" values, not the "parsed" or "submit" or "display" values.
Source:
Entity.js

rawValues

Gets "raw" values for this Entity.
Source:
Entity.js

getParsedValues

Gets an object of values for this Entity, Values are the "parsed" values, not the "raw" or "submit" or "display" values.
Source:
Entity.js

parsedValues

Gets "parsed" values for this Entity.
Source:
Entity.js

getChanged

Gets the values that have changed since last time saved
Source:
Entity.js

data

Alias for this.submitValues
Source:
Entity.js

getPropertiesBy

Get all Property objects that pass a supplied filter.
Source:
Entity.js

getIdProperty

Gets the "id" Property object for this Entity. This is the Property whose value represents the id for the whole Entity itself.
Source:
Entity.js

getId

Gets the id for this Entity.
Source:
Entity.js

id

Getter of the id for this Entity.
Source:
Entity.js

getDisplayProperty

Gets the "Display" Property object for this Entity. This is the Property whose value can easily identify the whole Entity itself.
Source:
Entity.js

getDisplayValue

Gets the "Display" value for this Entity. This value should easily identify the whole Entity itself.
Source:
Entity.js

displayValue

Getter of the "Display" value for this Entity. This value should easily identify the whole Entity itself.
Source:
Entity.js

isPhantom

Getter of isPhantom for this Entity. Entity is phantom if it has either no id or a temp id.
Source:
Entity.js

isDirty

Getter of isDirty for this Entity. Entity is dirty if it has any Property changes that have not been persisted to storage medium. Practically, this means it has any values that are different from this._originalData.
Source:
Entity.js

setId

Sets the id for this entity. Note: Does *not* fire any change events.
Source:
Entity.js

setValue

Sets a single Property value
Source:
Entity.js

setValues

Sets Property values
Source:
Entity.js

save

Tells the Repository to save this entity to the storage medium.
Source:
Entity.js

markSaved

Marks an entity as having been saved to storage medium.
Source:
Entity.js

markDeleted

Marks an entity as having been saved to storage medium.
Source:
Entity.js

delete

Tells the Repository to delete this entity from the storage medium.
Source:
Entity.js

destroy

Destroy this object. - Removes all circular references to parent objects - Removes child objects - Removes event listeners
Source:
Entity.js

Methods


<static> isTempId(id)

Determines whether submitted id is a "temp" id.
Parameters:
Name Type Description
id any
Source:
Entity.js
Returns:
isTempId
Type
boolean