new DBView(logger, database)
GraphDB constructor
Parameters:
| Name | Type | Description |
|---|---|---|
logger |
olympe.logging.Channel | |
database |
olympe.dc.db.Database |
Members
-
callbackLogs
-
DEVONLY
-
callbackLogsSnapshot
-
DEVONLY
-
logCallbacks
-
DEVONLY
Methods
-
countRelated(tag, type, direction)
-
Gets the amount of related instances at the time of the method call
Parameters:
Name Type Description tagolympe.dc.InstanceTag Instance tag
typestring Relation type tag
directionolympe.dc.Direction Relation direction
Returns:
- Type
- number
-
exist(tag)
-
Determines if the instance currently exists in the local DB.
Parameters:
Name Type Description tagolympe.dc.InstanceTag The instance
Returns:
if the instance is currently marked as exist in the db.
- Type
- boolean
-
extension(tag)
-
Returns the tag of the parent model of the instance given as parameter, if the instance exists and it it has a model. Returns null instead.
Parameters:
Name Type Description tagolympe.dc.InstanceTag The instance, represented by any of the option offered by InstanceTag
Returns:
the tag of the extended model
- Type
- string
-
findAllRelated(startTag, relations, predicate)
-
Find all the instances matching the provided predicate when following all the given relations (non recursive).
Parameters:
Name Type Description startTagolympe.dc.InstanceTag Tag of the starting instance
relationsArray.<!olympe.dc.registry.Relation> The relations to follow
predicatefunction Anonymous predicate function
Returns:
- Type
- Array.<string>
-
findRecursive(startTag, relation, predicate)
-
Find the first (random) instance matching a predicate when following recursively a given relation, including the start instance.
Parameters:
Name Type Description startTagolympe.dc.InstanceTag Tag of the starting instance
relationolympe.dc.registry.Relation The relation to follow recursively
predicatefunction Anonymous predicate function
Returns:
nullif no instance matchespredicate- Type
- string
-
findRelated(startTag, relations, predicate)
-
Find the first instance matching the provided predicate when following all the given relations (non recursive).
Parameters:
Name Type Description startTagolympe.dc.InstanceTag Tag of the starting instance
relationsArray.<!olympe.dc.registry.Relation> The relations to follow
predicatefunction Anonymous predicate function
Returns:
- Type
- string
-
getAnyRelated(tag)
-
Return an iterable object over all instances related to the specified instance, whatever the relation is. For each relation, an array of 3 strings is returned in that format : [relation tag, direction, related instance tag]
Parameters:
Name Type Description tagolympe.dc.InstanceTag The instance tag
Returns:
the iterable result
- Type
- Generator.<!Array.<string>>
-
getDefaultProperties(tag [, ownOnly])
-
Gets all default property values defined on this model instance.
Parameters:
Name Type Argument Default Description tagolympe.dc.InstanceTag Instance tag
ownOnlyboolean <optional>
false If true, returns only own properties (ie. not inherited)
Returns:
A map of all the default properties values indexed by property tag
- Type
- Map.<string, *>
-
getDefaultProperty(tag, property [, ownOnly])
-
Get the specified default property value of the specified instance.
Parameters:
Name Type Argument Default Description tagolympe.dc.InstanceTag Instance tag
propertyolympe.dc.InstanceTag The property
ownOnlyboolean <optional>
false If true, returns only own property (ie. not inherited)
Returns:
- Type
- *
-
getExtendedModels(modelTag [, endTag])
-
Get all the models extended by this model (including self). Optionally define an end tag to get a subset of extended models. Will throw an error if the expected end model is not found.
Parameters:
Name Type Argument Default Description modelTagolympe.dc.InstanceTag Tag of the starting model instance
endTagolympe.dc.InstanceTag <optional>
olympe.dc.CloudObject Optional end instance tag after which to stop following the extend relations.
Returns:
- Type
- Array.<string>
-
getFollowRule(relation, rule)
-
Return the follow rule associated to the specified rule, for the specified relations. Return 0 if no rule exist for it or if the instance is not a relation.
Parameters:
Name Type Description relationolympe.dc.InstanceTag ruleolympe.dc.FollowRules Returns:
- Type
- number
-
getId()
-
Return the identifier of the database
Returns:
- Type
- string
-
getImplicitRelated(tag, followRule)
-
Return an iterable object over all instances related to the specified one via relations with specified follow rules. It includes the initial instance.
Parameters:
Name Type Description tagolympe.dc.InstanceTag The root instance tag
followRuleolympe.dc.FollowRules The rule to apply to follow relations
Returns:
the iterable result
- Type
- Iterable.<string>
-
getIncomingRelations(tag)
-
Gets currently incoming relations: all relation whose the destination is the specified instance.
Parameters:
Name Type Description tagolympe.dc.InstanceTag The instance tag
Returns:
An array of incoming relation tags
- Type
- Array.<string>
-
getInstances(modelTag)
-
Get the current instances of a model.
Parameters:
Name Type Description modelTagolympe.dc.InstanceTag Tag of the model instance
Returns:
- Type
- Array.<string>
-
getMultiRelated(startTag, relations)
-
Get the currently related instances following all the specified relations (non recursive).
Parameters:
Name Type Description startTagolympe.dc.InstanceTag the instance to start with
relationsArray.<!olympe.dc.registry.Relation> Relations to follow
Returns:
The resulting array
- Type
- Array.<string>
-
getOutgoingRelations(tag)
-
Gets currently incoming relations: all relation whose the destination is the specified instance.
Parameters:
Name Type Description tagolympe.dc.InstanceTag The instance tag
Returns:
An array of incoming relation tags
- Type
- Array.<string>
-
getProperties(tag [, ownOnly])
-
Get a map of all property values of the specified instance.
Parameters:
Name Type Argument Default Description tagolympe.dc.InstanceTag The instance tag
ownOnlyboolean <optional>
false if true, the result does not include the inherited default properties.
Returns:
A map with all property values indexed by property tag
- Type
- Map.<string, ?*>
-
getProperty(tag, property [, ownOnly])
-
Get the value of an instance's property, or null if the property is not set.
Parameters:
Name Type Argument Default Description tagolympe.dc.InstanceTag The instance
propertyolympe.dc.InstanceTag The property to retrieve
ownOnlyboolean <optional>
false if true, the result does not include the inherited default properties.
Returns:
the current value or null
- Type
- *
-
getRecursiveRelated(startInstanceTag, relation [, endInstanceTag])
-
Follow the specified relation recursively and return all the instances found along the path(s) (unordered).
Parameters:
Name Type Argument Description startInstanceTagolympe.dc.InstanceTag Tag of the starting instance
relationolympe.dc.registry.Relation The relation to follow recursively
endInstanceTagolympe.dc.InstanceTag <optional>
Optional end instance tag at which to stop following
relation. If provided, only instances lying on a path somewhere betweenstartTagandendTag` will be returnedReturns:
All the instances found by following recursively
relation(unordered)- Type
- Array.<string>
-
getReferencingObject(tag)
-
If
tagis a complex property, returns the tag of the instance that references it. Return null if not.Parameters:
Name Type Description tagolympe.dc.InstanceTag Tag of the complex property
Returns:
- Type
- string
-
getRelated(tag, relation)
-
Gets the currently related instances following a specific relation (non recursive).
Parameters:
Name Type Description tagolympe.dc.InstanceTag The instance
relationolympe.dc.registry.Relation The relation to follow
Returns:
The resulting array of tags.
- Type
- Array.<string>
-
getUniqueRelated(tag, relation)
-
Gets the currently unique related instance tag (non recursive).
Parameters:
Name Type Description tagolympe.dc.InstanceTag The instance
relationolympe.dc.registry.Relation The relation to follow
Returns:
The tag, or
nullif there is no match or more than one match.- Type
- string
-
instanceOf(tag, modelTag)
-
Assess whether the instance
tagis instanceof the modelmodelTag. Note: if A is instance of B, and B extends C, A is an instance of both B and C.Parameters:
Name Type Description tagolympe.dc.InstanceTag Tag of the starting model instance
modelTagolympe.dc.InstanceTag Tag of the extended model instance
Returns:
- Type
- boolean
-
isExtending(modelTag, extendedTag)
-
Assess whether the model
modelTagis extending the modelextendedTag. Returns true if modelTag is equal to extendedTag.Parameters:
Name Type Description modelTagolympe.dc.InstanceTag Tag of the starting model instance
extendedTagolympe.dc.InstanceTag Tag of the extended model instance
Returns:
- Type
- boolean
-
isModel(tag)
-
Return whether the specified instance is a model or not
Parameters:
Name Type Description tagolympe.dc.InstanceTag The instance
Returns:
is the instance a model
- Type
- boolean
-
isPersisted(tag)
-
Return whether the specified instance is persisted or in memory volatile. By default, if the specified instance is not in the local database, it considers it's a persisted instance.
Parameters:
Name Type Description tagolympe.dc.InstanceTag The instance
Returns:
Persistence state of the instance.
- Type
- boolean
-
isRelated(tag, relation, related)
-
Return true if the specified instance is effectively related to the other instance with this relation.
Parameters:
Name Type Description tagolympe.dc.InstanceTag The instance
relationolympe.dc.registry.Relation The relation to follow
relatedolympe.dc.InstanceTag The related instance to look for
Returns:
Whether the instance is effectively related to the other specified instance.
- Type
- boolean
-
model(tag)
-
Return the tag of the model of the specified instance if there is one
Parameters:
Name Type Description tagolympe.dc.InstanceTag The instance
Returns:
the model tag
- Type
- string
-
name(tag)
-
Return the name of the specified instance, or an empty string if not found.
Parameters:
Name Type Description tagolympe.dc.InstanceTag The instance
Returns:
the name of the instance
- Type
- string
-
offAnyProperty(tag, id)
-
Unregisters an anyProperty callback from the specified instance
Parameters:
Name Type Description tagolympe.dc.InstanceTag The instance
idstring The id of the callback to unregister
-
offAnyRelation(tag, id [, noEvent])
-
Unregisters a callback on all relations of an instance. For each existing relation at the time of hte method call and unless otherwise specified, a REMOVED event will be immediately fired upon unregistration.
Parameters:
Name Type Argument Default Description tagolympe.dc.InstanceTag Instance tag
idstring Callback identifier
noEventboolean <optional>
false If true, no REMOVED event will be fired upon unregistration
-
offInstance(tag, id [, noEvent])
-
Unregisters a callback on an instance. Unless otherwise specified, calling this method will immediately trigger a REMOVED event.
Parameters:
Name Type Argument Default Description tagolympe.dc.InstanceTag Instance tag
idstring Callback identifier
noEventboolean <optional>
false If true, no REMOVED event will be fired upon unregistration
-
offProperty(tag, property, id)
-
Unregisters a property update callback from an instance.
Parameters:
Name Type Description tagolympe.dc.InstanceTag Instance tag.
propertyolympe.dc.InstanceTag The property tag.
idstring Callback identifier.
-
offRelation(tag, relation, id [, noEvent])
-
Unregisters a callback on an instance relation. For each existing relation at the time of the method call and unless otherwise specified, a REMOVED event will be immediately fired upon unregistration.
Parameters:
Name Type Argument Default Description tagolympe.dc.InstanceTag Instance tag
relationolympe.dc.registry.Relation The relation to listen to
idstring Callback identifier
noEventboolean <optional>
false If true, no REMOVED event will be fired upon unregistration
-
onAnyProperty(tag, callback [, id])
-
Registers a callback to be invoked any time a property of the specified instance gets a value.
Parameters:
Name Type Argument Description tagolympe.dc.InstanceTag The instance
callbackolympe.dc.DBView.AnyPropertyCallback the callback to register
idstring <optional>
Returns:
- Type
- string
-
onAnyRelation(tag, callback [, id])
-
Register a callback on an instance which is called every time the instance get a new relation. For each existing relation at the time of the method call, an ADDED event will be immediately fired. If two callbacks are registered with the same identifier, the last registered one will simply overwrite the first one.
Parameters:
Name Type Argument Description tagolympe.dc.InstanceTag Instance tag
callbackolympe.dc.DBView.RelationCallback Function to run when any relation is created or removed on the specified instance
idstring <optional>
Callback identifier
Returns:
Registered callback identifier
- Type
- string
-
onInstance(tag, callback [, id])
-
Register a callback on an instance. If the instance already exists at the time of the method call, an ADDED event will be immediately fired
Parameters:
Name Type Argument Description tagolympe.dc.InstanceTag Instance tag
callbackolympe.dc.DBView.InstanceCallback Callback function
idstring <optional>
Callback identifier
Returns:
Registered callback identifier
- Type
- string
-
onProperty(tag, property, callback [, id])
-
Registers a callback to be invoked when the specified property of the specified instance is updated.
Parameters:
Name Type Argument Description tagolympe.dc.InstanceTag Instance tag.
propertyolympe.dc.InstanceTag The property tag.
callbackolympe.dc.DBView.PropertyCallback Callback function.
idstring <optional>
Callback identifier.
Returns:
Registered callback identifier.
- Type
- string
-
onRelation(tag, relation, callback [, id])
-
Register a callback on an instance relation. For each existing relation at the time of the method call, an ADDED event will be immediately fired. Also, if two callbacks are registered with the same identifier, the last registered one will simply overwrite the first one.
Parameters:
Name Type Argument Description tagolympe.dc.InstanceTag Instance tag
relationolympe.dc.registry.Relation The relation to listen to
callbackolympe.dc.DBView.InstanceCallback Callback function
idstring <optional>
Callback identifier
Returns:
Registered callback identifier
- Type
- string
-
propertyDefinedOnModel(property, model)
-
Tells if the property given as first parameter is defined on the model given as second parameter. In other words, if an instance of the provided model is allowed to carry a value against the given property. Note that properties of possible super-model(s) of the model are considered as well
Parameters:
Name Type Description propertyolympe.dc.InstanceTag modelolympe.dc.InstanceTag Returns:
- Type
- boolean
-
source(tag)
-
Return the source of the specified instance.
Parameters:
Name Type Description tagolympe.dc.InstanceTag The instance
Returns:
the version, null if the instance does not exists
- Type
- string
-
version(tag)
-
Return the version of the specified instance.
Parameters:
Name Type Description tagolympe.dc.InstanceTag The instance
Returns:
the version, null if the instance does not exists
- Type
- number
Type Definitions
-
AnyPropertyCallback(name, value, isDefault)
-
Function to be called when any property changes.
Parameters:
Name Type Description namestring Property name that has received a value
value* Value of the property after the change.
isDefaultboolean trueif this value is meant to become the default value. -
InstanceCallback(added, tag)
-
Function to be called when an instance is added or removed.
Parameters:
Name Type Description addedboolean trueif this instance was added,falseif it was removed.tagstring Instance tag
-
PropertyCallback(value, isDefault)
-
Function to be called when a property changes.
Parameters:
Name Type Description value* Value of the property after the change.
isDefaultboolean trueif this value is meant to become the default value. -
RelationCallback(type, direction, added, tag)
-
Function to be called when a relation is added ore removed.
Parameters:
Name Type Description typestring Relation type.
directionolympe.dc.Direction Relation direction.
addedboolean trueif this relation was added,falseif it was removed.tagstring Instance tag.
Olympe SDK