entities~Entity(entityType)

An instance of an entity.

new Entity(entityType)

Constructs an entity.
Parameters:
Name Type Description
entityType EntityType The type of the entity.

Methods

addChild(relationshipType, childEntity) → {Relationship}

Adds a child entity of the given type.
Parameters:
Name Type Description
relationshipType RelationshipType The relationship type. Must not be null.
childEntity Entity The child entity.
Returns:
Relationship - - The created relationship.

addParent(relationshipType, parentEntity) → {Relationship}

Adds a parent entity of the given type.
Parameters:
Name Type Description
relationshipType RelationshipType The relationship type. Must not be null.
parentEntity Entity The parent entity.
Returns:
Relationship - - The created relationship.

destroy()

Destroys an entity. Removes all relationships from an to this entity. Also unregisters the entity from the entity type. TODO: check if this is enough to get being garbage collected.

getChildEntities(relationshipType) → {Array.<Entity>}

Returns the child entities.
Parameters:
Name Type Description
relationshipType RelationshipType Restricts which types of relationships have to be respected or null for any type.
Returns:
Array.<Entity> - The child entities.

getIncomingRelationships(relationshipType) → {Array.<Relationship>}

Returns the incoming relationships.
Parameters:
Name Type Description
relationshipType RelationshipType Restricts which types of relationships have to be respected or null for any type.
Returns:
Array.<Relationship> - The list of incoming relationships of the given type.

getOutgoingRelationships(relationshipType) → {Array.<Relationship>}

Returns the outgoing relationships.
Parameters:
Name Type Description
relationshipType RelationshipType Restricts which types of relationships have to be respected or null for any type.
Returns:
Array.<Relationship> - The list of outgoing relationships of the given type.

getParentEntities(relationshipType) → {Array.<Entity>}

Returns the parent entities.
Parameters:
Name Type Description
relationshipType RelationshipType Restricts which types of relationships have to be respected or null for any type.
Returns:
Array.<Entity> - The parent entities.

getType() → {EntityType}

Returns the entity type.
Returns:
EntityType - The type of the entity.

getUuid() → {string}

Returns the UUID of the entity.
Returns:
string - The uuid of the entity.

isChildEntity(childEntity, relationshipType) → {Boolean}

Returns true, if an outgoing relationship of the given type exists to the given entity.
Parameters:
Name Type Description
childEntity Entity The child entity.
relationshipType RelationshipType The relationship type or null.
Returns:
Boolean - True, if childEntity is a child entity.

isParentEntity(parentEntity, relationshipType) → {Boolean}

Returns true, if an incoming relationship of the given type exists to the given entity.
Parameters:
Name Type Description
parentEntity Entity The parent entity.
relationshipType RelationshipType The relationship type or null.
Returns:
Boolean - True, if parentEntity is a parent entity.

removeChildEntity(relationshipType, childEntity)

Removes all relationships of the given type to the given child entity.
Parameters:
Name Type Description
relationshipType RelationshipType The relationship type or null.
childEntity Entity The child entity.

removeParentEntity(relationshipType, parentEntity)

Removes all relationships of the given type to the given parent entity.
Parameters:
Name Type Description
relationshipType RelationshipType The relationship type or null.
parentEntity Entity The parent entity.