new Transaction( [id])
Creates an instance of Transaction.
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
id |
string |
<optional> |
Optional transaction identifier. |
- Implements:
Methods
-
addOperation(operation)
-
Adds an operation to the transaction.
Parameters:
Name Type Description operationolympe.dc.Operation Operation to add.
Returns:
The added operation.
- Type
- olympe.dc.Operation
-
afterExecution(callback)
-
Register a callback on the transaction execution.
Parameters:
Name Type Description callbackolympe.dc.Manager.TransactionCallback the callback to run when the transaction has finished.
-
build(patchGenerator)
-
Build the transaction into a
Patch.Parameters:
Name Type Description patchGeneratorolympe.dc.transaction.PatchGenerator The patch generator to use for building.
- Implements:
-
create(model [, tag])
-
Creates an instance of the specified model.
Parameters:
Name Type Argument Description modelolympe.dc.InstanceTag The model.
tagolympe.dc.InstanceTag <optional>
Tag of the newly created instance, if omitted it will be automatically generated.
Returns:
The created
Operation. -
createModel(nameOrProperties [, model] [, parent] [, tag])
-
Create a new model.
Parameters:
Name Type Argument Description nameOrPropertiesstring | Object Model name or model properties.
modelolympe.dc.InstanceTag <optional>
Model of the new model tag (will be Object if not specified).
parentolympe.dc.InstanceTag <optional>
Parent model of the object if different of Object.
tagstring <optional>
New model instance tag.
Returns:
The
Create instanceoperation for the new model. -
createRelation(rel, from, to)
-
Create a relation between two instances.
Parameters:
Name Type Description relolympe.dc.InstanceTag The relation to create.
fromolympe.dc.InstanceTag The origin instance.
toolympe.dc.InstanceTag The destination instance.
-
defineProperty(model, type [, name] [, goo] [, defaultValue] [, tag])
-
Adds a property to the specified model.
Parameters:
Name Type Argument Default Description modelolympe.dc.InstanceTag The model.
typeolympe.dc.InstanceTag The Property type.
namestring <optional>
'' Property name.
gooolympe.dc.InstanceTag <optional>
The group of object it belongs to.
defaultValue* <optional>
Default value for instances of the related model.
tagstring <optional>
the property's tag.
Returns:
The
Create Instanceoperation for the model. -
defineRelation(originModel, destinationModel [, name], options [, tag])
-
Creates a relation type for connecting the specified models.
Parameters:
Name Type Argument Default Description originModelolympe.dc.InstanceTag Tag or model for the origin.
destinationModelolympe.dc.InstanceTag Tag or model for the destination.
namestring <optional>
'' Relation name.
optionsObject Options to apply.
Properties
Name Type Argument Description cardinalityolympe.dm.Relation.CARDINALITY <optional>
Cardinality of the relation.
permissionTypenumber <optional>
required permissions to create a relation
dumpFollowRulesolympe.dm.Relation.FOLLOW_RULES_VALUES <optional>
Dump follow rules.
deleteFollowRulesolympe.dm.Relation.FOLLOW_RULES_VALUES <optional>
Delete follow rules.
runtimeFollowRulesolympe.dm.Relation.FOLLOW_RULES_VALUES <optional>
Execute follow rules.
flagsnumber <optional>
The flags.
tagstring <optional>
The relation tag. If omitted one will be automatically generated.
Returns:
The operation that creates the relation model.
-
delete(tag [, followRule])
-
Deletes a specific instance. The specified follow rule determines the delete strategy to use : what rule must be used to propagate the delete through relations in the graph.
Note that the rule can be NONE (@see
olympe.dc.FollowRules.NONE), in which case the instance only will be deleted when the transaction is executed (as long it has no relation attached).Parameters:
Name Type Argument Default Description tagolympe.dc.InstanceTag The instance to delete.
followRuleolympe.dc.FollowRules <optional>
olympe.dc.FollowRule.DELETE the delete strategy rule to use.
-
deleteAllInstances(model [, followRule])
-
Deletes all instances of the specified model. The specified follow rule determines the delete strategy to use : what rule must be used to propagate the delete through relations in the graph.
Note that the rule can be NONE (@see
olympe.dc.FollowRules.NONE), in which case the instance only will be deleted when the transaction is executed (as long it has no relation attached).Parameters:
Name Type Argument Default Description modelolympe.dc.InstanceTag The model.
followRuleolympe.dc.FollowRules <optional>
olympe.dc.FollowRule.DELETE the delete strategy rule to use.
-
deleteAllRelations(rel, origin [, deleteDestinations] [, excludes])
-
Delete all relations of a specific type.
Parameters:
Name Type Argument Default Description relolympe.dc.InstanceTag The relation or its tag.
originolympe.dc.InstanceTag The origin instance.
deleteDestinationsboolean <optional>
false trueto delete the destination instances as well.excludesArray.<olympe.dc.InstanceTag> <optional>
List of instances to exclude.
-
deleteRelation(rel, from, to [, deleteDestination] [, forceDelete])
-
Deletes a relation between two instances.
Parameters:
Name Type Argument Default Description relolympe.dc.InstanceTag The relation.
fromolympe.dc.InstanceTag The origin instance.
toolympe.dc.InstanceTag The destination instance.
deleteDestinationboolean <optional>
false trueto delete the destination instance as well.forceDeleteboolean <optional>
false trueto force the delete. -
execute( [callback] [, waitForNotification])
-
Execute this transaction and send it to the data-cloud.
Parameters:
Name Type Argument Description callbackolympe.dc.Manager.TransactionCallback <optional>
the callback to run when the transaction has finished.
waitForNotificationboolean <optional>
If
true, wait for the transaction to have been notified to all clients before calling back. Iffalse, call back as soon as the transaction has been accepted. -
executeAsLarge( [callback])
-
Execute this transaction and send it to the data-cloud over HTTP instead of WS.
Parameters:
Name Type Argument Description callbackolympe.dc.Manager.TransactionCallback <optional>
the callback to run when the transaction has finished.
-
getCount()
-
Return the number of operations included in this transaction.
Returns:
The operations count.
- Type
- number
-
getId()
-
Gets this transaction's identifier.
Returns:
The ID.
- Type
- string
-
isReversible()
-
Check if the transaction can be used for undo/redo
Returns:
- Type
- boolean
-
persist(persist)
-
Sets whether operations of the
Transactionshould be 'persisted' or not. When a transaction is set to not persist operations, it is executed locally but nothing is send to the data-cloud. (local or remote). By default transactions persist the operations.Parameters:
Name Type Description persistboolean falsemake this transaction in memory onlyReturns:
this
-
persistInstance(tag [, persist])
-
Mark the specified instance to be persisted. If the instance does not exist yet, throws an error.
Parameters:
Name Type Argument Default Description tagolympe.dc.InstanceTag persistboolean <optional>
true Returns:
The created
Operation. -
setAsReversible()
-
Sets this transaction as reversible (for undo/redo).
Returns:
-
setLocal(local)
-
Sets whether a
Transactionshould be 'local' or not. When a transaction is made 'local' every operation is executed locally but not persisted in the data-cloud. By default transactions are not 'local'.Parameters:
Name Type Description localboolean trueto make this transaction local.- Deprecated:
-
- use
olympe.dc.Transaction#persistinstead
- use
Returns:
this
-
setParentModel(model, parentModel)
-
Adds a parent model to the specified model, thus extending the model.
Parameters:
Name Type Description modelolympe.dc.InstanceTag The model to extend.
parentModelolympe.dc.InstanceTag The parent model.
-
toString()
-
Gets a string representation of the operation
- Implements:
Returns:
- Type
- string
-
update(instance [, property] [, value])
-
Updates the value of a property of an instance.
Parameters:
Name Type Argument Description instanceolympe.dc.InstanceTag The instance.
propertyolympe.dc.InstanceTag <optional>
The property.
valueolympe.df.OString | olympe.df.ONumber | olympe.df.OBoolean | olympe.df.Color | olympe.df.ODateTime | olympe.dc.Reference | string | number | boolean | olympe.df.Node | olympe.df.Proxy <optional>
<nullable>
The new value.
Returns:
The update operation.
Olympe SDK