Class: PatchSerializer

olympe.dc.transaction. PatchSerializer

This class collects database operations (thru its olympe.dc.Writable methods), and serialize these operations into a buffer


new PatchSerializer( [separateComplexProps])

Parameters:
Name Type Argument Default Description
separateComplexProps boolean <optional>
false
Implements:

Methods


createInstance(tag [, properties] [, id])

Creates an instance and returns it's tag

Parameters:
Name Type Argument Description
tag string

New instance tag

properties Map.<string, ?*> <optional>

Instance's properties (map of properties names to values)

id number <optional>

operationId

Implements:

createRelation(type, leftTag, rightTag [, id])

Creates a relation between two instances.

Parameters:
Name Type Argument Default Description
type string

Tag of the relation

leftTag string

Left instance tag

rightTag string

Right instance tag

id number <optional>
-1

operationId

Implements:

deleteInstance(tag [, followRule] [, id])

Deletes an instance

  • Removing a non existing instance does not trigger an error
  • Removing an instance that still has relations does not trigger an error
Parameters:
Name Type Argument Description
tag string
followRule olympe.dc.FollowRules <optional>
id number <optional>

operationId

Implements:

deleteRelation(type, leftTag, rightTag [, id])

Removes a relation between two instances

Parameters:
Name Type Argument Default Description
type string

Tag of the relation

leftTag string

Left instance tag

rightTag string

Right instance tag

id number <optional>
-1

operationId

Implements:

flush()

Returns and clears the serialization output

Returns:
Type
string

flushArray()

Returns the serialized patch as an array, ready to be stringify and clears the serializer

Returns:
Type
Array

flushObject()

Return all accumulated operations split by types.

Returns:
Type
olympe.dc.transaction.PatchSerializer.MultiPatchContents

reset()

Resets the serialization output


updateInstance(tag [, properties] [, forceUpdate] [, id])

Updates an instance.

  • If the instance does not exist, it will be automatically created
  • Depending on the implementation, updates will be rejected if the provided "new" version is lower than the stored one
Parameters:
Name Type Argument Default Description
tag string

Instance tag

properties Map.<string, ?*> <optional>

Instance properties

forceUpdate boolean <optional>
false

If true, do not do any version check and accepts any update (used by rollbacks)

id number <optional>

operationId

Implements:

Type Definitions


MultiPatchContents

Type:
  • Object
Properties:
Name Type Argument Description
deleteRelations Array.<!Object> <nullable>
deleteInstances Array.<!Object> <nullable>
newInstances Array.<!Object> <nullable>
updateInstances Array.<!Object> <nullable>
newRelations Array.<!Object> <nullable>

PatchContent

NB: Use quoted property names (e.g. content['rootTag']) to prevent Google Closure from optimizing them out. These properties must be preserved to be serialized in JSON files. They are required by the Orchestrator.

Type:
  • Object
Properties:
Name Type Description
o number
m string
l string
r string
f olympe.dc.FollowRules
p Object
i number