<package> new InstancePatch(tag)
Parameters:
Name | Type | Description |
---|---|---|
tag |
string |
Members
-
<static> STATE_ID :number
-
States of an instance
Type:
- number
Properties:
Name Type Default Description NEW
number 0 UPDATE
number 1 DELETE
number 2 -
<protected> properties :Map.<string, ?*>
-
Type:
- Map.<string, ?*>
-
<protected> relations :Map.<string, !Map.<string, boolean>>
-
Type:
- Map.<string, !Map.<string, boolean>>
-
<protected, non-null> state :olympe.dc.db.InstancePatch.State
-
Type:
-
<protected> t :string
-
Type:
- string
Methods
-
<static> fromJSON(json)
-
Deserializes an
InstancePatch
from a JSON object or string.Parameters:
Name Type Description json
string | Object Returns:
-
addProperties(properties)
-
Set multiple properties to this instance patch.
Parameters:
Name Type Description properties
Map.<string, ?*> Returns:
this
-
addProperty(property, value)
-
Set a new value for the specified property. Null means the clear of the value.
Parameters:
Name Type Argument Description property
string value
* <nullable>
Returns:
this
-
<package> clearLink(relation, direction, related)
-
Remove any operation on the specified relation from this instance patch. Return true if the clear had an effect in this patch or not.
Parameters:
Name Type Description relation
string direction
string related
string Returns:
whether the operation had an effect of not
- Type
- boolean
-
clearProperty(property)
-
Remove the property value from this patch.
Parameters:
Name Type Description property
string Returns:
this
-
clone()
-
Return a clone of this instancePatch
Returns:
the clone
-
<package> create()
-
Set the state of the instance event to "new"
Returns:
this
-
<package> delete( [followRule])
-
Set the state of the instance event to "delete".
Parameters:
Name Type Argument Default Description followRule
olympe.dc.FollowRules <optional>
olympe.dc.FollowRules.NONE Returns:
this
-
<package> forceUpdate()
-
Set the state of the instance event to "force update".
Returns:
this
-
getAllRelations(formatter)
-
Return an iterable over all relations of this instance. The result values is formatted according to the specified formatter. By default, the format is: [relation tag, direction, related tag, added]
Parameters:
Name Type Description formatter
function Returns:
- Type
- Generator.<T>
-
getInverseRelations(formatter)
-
Return an iterator over all relations whose the destination is this instance. The result values is formatted according to the specified formatter. By default, the format is: [relation tag, origin tag, added]
Parameters:
Name Type Description formatter
function Returns:
- Type
- Generator.<T>
-
getModel()
-
Return the model of that instance.
Returns:
- Type
- string
-
getProperties()
-
Return an iterable over all property values of this instance patch.
Returns:
- Type
- Map.<string, ?*>
-
getProperty(property)
-
Return the value of the specified property. It returns undefined if no property is defined. Null means that the patch clears the property value.
Parameters:
Name Type Description property
string Returns:
the property value
- Type
- * | undefined
-
getRelated(relation, formatter)
-
Return an iterator over all instances related to this instance with the specified relation. The result values is formatted according to the specified formatter. By default, the format is: [related tag, added]
Parameters:
Name Type Description relation
olympe.dc.registry.Relation formatter
function Returns:
- Type
- Generator.<T>
-
getRelations(formatter)
-
Return an iterator over all relations whose the origin is this instance. The result values is formatted according to the specified formatter. By default, the format is: [relation tag, destination tag, added]
Parameters:
Name Type Description formatter
function Returns:
- Type
- Generator.<T>
-
getSize()
-
Return the number of basic patch operations contained in this instance patch.
Returns:
- Type
- number
-
<package> getState()
-
Return this instance patch state
Returns:
-
getUniqueRelated(relation)
-
Returns the uniquely related instance, if it exists.
Parameters:
Name Type Description relation
olympe.dc.registry.Relation Returns:
The related instance or
null
- Type
- string
-
hasProperties()
-
Return whether or not this instance patch contains property updates
Returns:
- Type
- boolean
-
isDeleted()
-
Return whether this instance patch is the result of a delete instance operation or not.
Returns:
- Type
- boolean
-
<package> isLinked(relation, direction, related)
-
Return true if there is a create relation operation with the specified other instance in this patch, false if this is a delete relation operation and undefined if the relation is not in this patch.
Parameters:
Name Type Description relation
string direction
olympe.dc.Direction related
string Returns:
- Type
- boolean | undefined
-
isNew()
-
Return whether this instance patch is the result of a create instance operation or not.
Returns:
- Type
- boolean
-
<package> link(relation, destination)
-
Add a create relation operation to this instance patch for a relation going out of this instance.
Parameters:
Name Type Description relation
string destination
string Returns:
this
-
<package> linkOrigin(relation, origin)
-
Add a create relation operation to this instance patch for a relation coming in to this instance.
Parameters:
Name Type Description relation
string origin
string Returns:
this
-
tag()
-
Return the tag of the instance concerned by this patch
Returns:
- Type
- string
-
toJSON()
-
Serializes this
InstancePatch
into a JSON string.Returns:
- Type
- string
-
<package> unlink(relation, destination)
-
Add a delete relation operation to this instance patch for a relation going out of this instance.
Parameters:
Name Type Description relation
string destination
string Returns:
this
-
<package> unlinkOrigin(relation, origin)
-
Add a delete relation operation to this instance patch for a relation coming in to this instance.
Parameters:
Name Type Description relation
string origin
string Returns:
this
Type Definitions
-
InstanceGetter(tag)
-
Parameters:
Name Type Description tag
string the instance tag
Returns:
the instance if exists
- Type
- olympe.dc.db.InstancePatch | undefined
-
InstanceType
-
Type:
- Object
Properties:
Name Type Description id
olympe.dc.db.InstancePatch.STATE_ID extra
boolean | number -
State
-
Type:
- Object
Properties:
Name Type Description id
olympe.dc.db.InstancePatch.STATE_ID extra
olympe.dc.FollowRules | boolean | undefined