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 operation
olympe.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 callback
olympe.dc.Manager.TransactionCallback the callback to run when the transaction has finished.
-
build(patchGenerator)
-
Build the transaction into a
Patch
.Parameters:
Name Type Description patchGenerator
olympe.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 model
olympe.dc.InstanceTag The model.
tag
olympe.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 nameOrProperties
string | Object Model name or model properties.
model
olympe.dc.InstanceTag <optional>
Model of the new model tag (will be Object if not specified).
parent
olympe.dc.InstanceTag <optional>
Parent model of the object if different of Object.
tag
string <optional>
New model instance tag.
Returns:
The
Create instance
operation for the new model. -
createRelation(rel, from, to)
-
Create a relation between two instances.
Parameters:
Name Type Description rel
olympe.dc.InstanceTag The relation to create.
from
olympe.dc.InstanceTag The origin instance.
to
olympe.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 model
olympe.dc.InstanceTag The model.
type
olympe.dc.InstanceTag The Property type.
name
string <optional>
'' Property name.
goo
olympe.dc.InstanceTag <optional>
The group of object it belongs to.
defaultValue
* <optional>
Default value for instances of the related model.
tag
string <optional>
the property's tag.
Returns:
The
Create Instance
operation for the model. -
defineRelation(originModel, destinationModel [, name], options [, tag])
-
Creates a relation type for connecting the specified models.
Parameters:
Name Type Argument Default Description originModel
olympe.dc.InstanceTag Tag or model for the origin.
destinationModel
olympe.dc.InstanceTag Tag or model for the destination.
name
string <optional>
'' Relation name.
options
Object Options to apply.
Properties
Name Type Argument Description cardinality
olympe.dm.Relation.CARDINALITY <optional>
Cardinality of the relation.
permissionType
number <optional>
required permissions to create a relation
dumpFollowRules
olympe.dm.Relation.FOLLOW_RULES_VALUES <optional>
Dump follow rules.
deleteFollowRules
olympe.dm.Relation.FOLLOW_RULES_VALUES <optional>
Delete follow rules.
runtimeFollowRules
olympe.dm.Relation.FOLLOW_RULES_VALUES <optional>
Execute follow rules.
flags
number <optional>
The flags.
tag
string <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 tag
olympe.dc.InstanceTag The instance to delete.
followRule
olympe.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 model
olympe.dc.InstanceTag The model.
followRule
olympe.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 rel
olympe.dc.InstanceTag The relation or its tag.
origin
olympe.dc.InstanceTag The origin instance.
deleteDestinations
boolean <optional>
false true
to delete the destination instances as well.excludes
Array.<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 rel
olympe.dc.InstanceTag The relation.
from
olympe.dc.InstanceTag The origin instance.
to
olympe.dc.InstanceTag The destination instance.
deleteDestination
boolean <optional>
false true
to delete the destination instance as well.forceDelete
boolean <optional>
false true
to force the delete. -
execute( [callback] [, waitForNotification])
-
Execute this transaction and send it to the data-cloud.
Parameters:
Name Type Argument Description callback
olympe.dc.Manager.TransactionCallback <optional>
the callback to run when the transaction has finished.
waitForNotification
boolean <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 callback
olympe.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
Transaction
should 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 persist
boolean false
make 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 tag
olympe.dc.InstanceTag persist
boolean <optional>
true Returns:
The created
Operation
. -
setAsReversible()
-
Sets this transaction as reversible (for undo/redo).
Returns:
-
setLocal(local)
-
Sets whether a
Transaction
should 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 local
boolean true
to make this transaction local.- Deprecated:
-
- use
olympe.dc.Transaction#persist
instead
- use
Returns:
this
-
setParentModel(model, parentModel)
-
Adds a parent model to the specified model, thus extending the model.
Parameters:
Name Type Description model
olympe.dc.InstanceTag The model to extend.
parentModel
olympe.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 instance
olympe.dc.InstanceTag The instance.
property
olympe.dc.InstanceTag <optional>
The property.
value
olympe.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.