Class: Sync

olympe.dc. Sync

A Sync is the base class for all DataCloud object. In essence it represents a remote reference to an object in the data cloud. It is identified by its unique ID, or tag. From a Sync you can access related Objects, like its model or properties. A Sync is usually accessed via the DataCloud manager.

Example:

const s = manager.getSync(tag, olympe.df.Vector2);
const x = s.getPropertyAsNumber(xTag);

new Sync(manager, tag)

Creates an instance of a Sync.

Parameters:
Name Type Description
manager olympe.dc.Manager | undefined

Data cloud manager instance

tag string

Instance tag

Implements:

Members


<static> containsRel


<static> extendedByRel


<static> extendRel


<static> instancesRel


<static> modelRel


<static> nameProp


<static> propertyRel


<protected, non-null> db :olympe.dc.DBView

Type:

<protected> manager :olympe.dc.Manager

Type:

<non-null> model :olympe.dc.Sync

Type:

<protected> tag :string

Type:
  • string

Methods


<static> createInstance(transaction, model [, name], args)

Creates an instance for the specified model.

Parameters:
Name Type Argument Description
transaction olympe.dc.Transaction

The Transaction that will perform the creation.

model olympe.dc.InstanceTag

The Model for the instance.

name string | olympe.df.POString <optional>

The name to give that instance.

args * <repeatable>

Extra arguments passed to the factory method if any. If no factory is specified the default behavior is to treat the first args as the name of the created object.

Returns:

The ID of the created instance.

Type
string

<static> getInstance(instance)

Return the Sync instance of the specified tagOrConstructor

Parameters:
Name Type Description
instance olympe.dc.InstanceTag
Returns:
Type
olympe.dc.Sync

<static> getInstancesOf(tagOrConstructor)

Return the listdef of all instances of the specified tagOrConstructor

Parameters:
Name Type Description
tagOrConstructor olympe.dc.InstanceTag
Returns:
Type
olympe.dc.ListDef

<package, static> instantiate(entry, tag, container, model)

Instantiates the specified entry as a Sync. The specified tag is used for this instance. It may not be related to a instance in the datacloud but be used for runtime purposes.

Parameters:
Name Type Description
entry olympe.dc.registry.Entry
tag string
container olympe.di.Container
model olympe.dc.Sync
Returns:
Type
olympe.dc.Sync

currentName()

Returns:

The current name of this sync

Type
string

detachDelete( [transaction])

Remove all relations linked to the current sync and then remove the sync itself.

Parameters:
Name Type Argument Description
transaction olympe.dc.Transaction <optional>

equals(obj)

Checks whether 2 Syncs are equal.

Parameters:
Name Type Description
obj *

The object to compare with.

Returns:

true if this Sync is the same as the obj

Type
boolean

forEachRelated(relation, callback)

Register a callback to be called each time a specific relation is added to this object.

Note: If relations are already established at the time of calling, then the callback will be immediately invoked for each existing relation.

Parameters:
Name Type Description
relation olympe.dc.registry.Relation

The relation to follow

callback function

The function to invoke.


getContainer()

Gets the container of this instance.

Returns:

The container.

Type
olympe.dc.Sync | olympe.df.Proxy.<olympe.dc.Sync>

getContents()

Get the instances set as content by this instance.

Returns:

The set of instances.

Type
olympe.dc.ListDef.<!olympe.dc.Sync>

getCurrentFirstRelated(relation [, tagsOnly])

Get the currently first related object, or its tag, matching the specified transformer.

Parameters:
Name Type Argument Default Description
relation olympe.dc.registry.Relation

Relation to follow

tagsOnly boolean <optional>
false

true to return a tag (string), false for a Sync.

Deprecated:
  • Yes
Returns:

The tag or Sync. null if there is no match.

Type
olympe.dc.Sync | string

getCurrentRelated(relation [, tagsOnly])

Gets the currently related objects, or their tags, matching the specified transformer.

Parameters:
Name Type Argument Default Description
relation olympe.dc.registry.Relation

Relation to follow

tagsOnly boolean <optional>
false

true to return an array of tags (strings), false for an array of Syncs.

Deprecated:
  • Yes
Returns:

The resulting array of tags or Syncs.

Type
!Array.<olympe.dc.Sync> | Array.<string>

getDeleteOperation()

Gets an Operation to delete this instance, and all its dependencies. This implementation is based on the follow rules stored into the datamodel. It aims at still offering a "deleteOperation" while maintaining coherency with follow rules.

Deprecated:
Returns:

A transaction operation that will delete this model and all its instances.

Type
olympe.dc.Transaction

getDisplayName()

Gets the name of this Sync, defaulting to a string representation of this object.

Returns:

The display name of this Sync.

Type
olympe.df.POString

getExtendedModels()

Gets all the parent models for this model, recursively.

Deprecated:
  • Use olympe.dc.ModelInfo.getExtendedModelsFrom() instead.
Returns:

A list of all the parent models.

Type
olympe.dc.ListDef

getFirstRelated(related [, valueType])

Gets the first object related to this one by the specified relation.

Parameters:
Name Type Argument Description
related olympe.dc.registry.Relation

The transformer specifying the type of relation.

valueType function <optional>

Type of the values, must be sub-class of Sync.

Returns:

The first object matching the request.

Type
olympe.dc.Sync | T | olympe.df.Proxy.<T>

getGroupOfObjects()

Gets the Group of Objects this Sync belongs to.

Returns:

The list of GroupOfObject.

Type
olympe.dc.ListDef.<!olympe.dm.GroupOfObjects>

getIncomingPropertiesDefs()

Gets all properties definitions that have this Sync as a type.

Deprecated:
  • Yes
Returns:

The list of property definitions

Type
olympe.dc.ListDef.<!olympe.dm.Property>

getInheritedPropertiesDefs()

Gets all properties definitions inherited by this Sync.

Deprecated:
  • Yes
Returns:

The list of property definitions.

Type
olympe.dc.ListDef.<!olympe.dm.Property>

getInstances()

Gets all instances of this model.

Deprecated:
Returns:

The list of instances.

Type
olympe.dc.ListDef

getManager()

Gets the related DataCloud manger.

Returns:

The manager.

Type
olympe.dc.Manager

getModel()

Gets the model of this Sync.

Returns:

The model of this Sync.

Type
olympe.dc.Sync

getModelAndParentModels()

Returns the model of this instance, and any parent models of this model.

Deprecated:
Returns:
Type
olympe.dc.ListDef.<olympe.dc.Sync>

getModelTag()

Gets the tag of the model of this Sync.

Returns:

The tag of the model.

Type
string

getName()

Gets the name of this Sync.

Returns:

The name of this Sync.

Type
olympe.df.POString

getOwner()

Gets the owner for this Sync.

Returns:

The user who owns this Sync.

Type
olympe.dm.User | olympe.df.Proxy.<olympe.dm.User>

getOwnPropertiesDefs()

Gets all properties definitions defined on this Sync.

Deprecated:
  • Use olympe.dc.ModelInfo.getOwnPropertiesFrom() and olympe.dc.ModelInfo.getOwnRelationsFrom() instead.
Returns:

The list of property definitions

Type
olympe.dc.ListDef.<!olympe.dm.Property>

getParentModel()

Gets the immediate parent model for this model.

Deprecated:
  • Use olympe.dc.ModelInfo.getExtendedModelFrom() instead.
Returns:

The parent model.

Type
olympe.dc.Sync | olympe.df.Proxy.<olympe.dc.Sync>

getPropertiesDefs()

Gets all properties definitions inherited and defined by this Sync.

Deprecated:
  • Use olympe.dc.ModelInfo.getPropertiesFrom() and olympe.dc.ModelInfo.getRelationsFrom() instead.
Returns:

The list of property definitions.

Type
olympe.dc.ListDef.<!olympe.dm.Property>

getProperty(property)

Return the current value of the specified property of this object.

Parameters:
Name Type Description
property olympe.dc.InstanceTag
Returns:
Type
*

getPropertyAsBoolean(tag)

Gets a property value as an OBoolean.

Parameters:
Name Type Description
tag olympe.dc.InstanceTag

The tag of the property.

Returns:

The value of the property.

Type
olympe.df.POBoolean

getPropertyAsColor(tag)

Gets a property value as a Color.

Parameters:
Name Type Description
tag olympe.dc.InstanceTag

The tag of the property.

Returns:

The value of the property.

Type
olympe.df.PColor

getPropertyAsDateTime(tag)

Gets a property value as an ODateTime.

Parameters:
Name Type Description
tag olympe.dc.InstanceTag

The tag of the property.

Returns:

The value of the property.

Type
olympe.df.PODateTime

getPropertyAsNumber(tag)

Gets a property value as an ONumber.

Parameters:
Name Type Description
tag olympe.dc.InstanceTag

The tag of the property.

Returns:

The value of the property.

Type
olympe.df.PONumber

getPropertyAsString(tag)

Gets a property value as an OString.

Parameters:
Name Type Description
tag olympe.dc.InstanceTag

The tag of the property.

Returns:

The value of the property.

Type
olympe.df.POString

getPropertyAsSync(tag)

Gets a property value as a Sync.

Parameters:
Name Type Description
tag olympe.dc.InstanceTag

The tag of property.

Returns:

The value of the property.

Type
olympe.df.Proxy.<olympe.dc.Sync> | olympe.dc.Sync

getRawProperty(prop, valueCaster, valueType)

Gets a property raw value, optionally processing it with the specified callback.

Parameters:
Name Type Description
prop olympe.dc.InstanceTag

Property.

valueCaster olympe.dc.Sync.ValueCaster

Optional 'casting' function.

valueType function

The Type for the property.

Returns:

The created node.

Type
olympe.df.Node.<T>

getRelated(relation [, valueType])

Gets all the objects related to this one by the specified relation.

Parameters:
Name Type Argument Description
relation olympe.dc.registry.Relation

The relation to follow.

valueType function <optional>

Type of the values, must be sub-class of Sync.

Returns:

A list of objects matching the request.

Type
olympe.dc.ListDef.<T>

getSource()

Gets the source of this Sync.

Returns:

The source.

Type
string

getTag()

Gets the unique tag of this Sync.

Implements:
Returns:

The tag.

Type
string

getVersion()

Gets the version of this Sync.

Returns:

The version.

Type
number

isModel()

Checks whether this Sync is a model (i.e. it has a parent model).

Deprecated:
  • Use olympe.dc.utils.isAModel() instead.
Returns:

true if this Sync is a model.

Type
olympe.df.POBoolean

observeProperty(property)

Return an observable to the value of the specified property of this object.

Parameters:
Name Type Description
property olympe.dc.InstanceTag
Returns:
Type
rxjs.Observable

oEquals(otherSync)

Checks whether this olympe.dc.Sync is equal to another Sync.

Parameters:
Name Type Description
otherSync *

The object to compare with.

Returns:

true if both syncs have the same tag, false otherwise

Type
olympe.df.POBoolean

toListDef()

Returns a ListDef whose query has only the current sync as start point.

Returns:

The created ListDef.

Type
olympe.dc.ListDef

toOString()

Convert current object to a string representation. By default, this function simply returns what getDisplayName() returns, but this simplistic behavior should typically overridden by sibling classes.

Returns:

The string representation.

Type
olympe.df.POString

toString()


transform(transformers)

Creates a ListDef representing a query which will apply the provided transformers to this Sync.

Parameters:
Name Type Argument Description
transformers olympe.dc.Transformer | Array.<olympe.dc.Transformer> <repeatable>

The transformers to apply. Note that an error is thrown if an array is passed as first argument, there is more than one arguments.

Returns:

The created ListDef.

Type
olympe.dc.ListDef

Type Definitions


ValueCaster(value)

A ValueCaster is a function performing the conversion (or 'casting') of a raw value into a typed value.

Parameters:
Name Type Description
value *

Raw value from database.

Returns:

value Casted value.

Type
*