Protected
rootThe root type for this storage.
Use this instead of rootTypeVar to prevent having to check for undefined
.
This value will always be defined if the type definitions have been validated.
Creates an object of the given type. The storage will generate an identifier for the newly created object.
The type to create.
The value to set for the created object.
A representation of the newly created object, including its new identifier.
Creates an index on a key of the given type, to allow for better queries involving those keys. Similar to IndexedStorage.defineType these calls need to happen first.
Informs the storage of the definition of a specific type. A definition is a key/value object with the values being a valid ValueTypeDescription. Generally, this call needs to happen for every type of this storage, and before any calls are made to interact with the data.
Returns an iterator over all objects of the given type.
The type to iterate over.
Finds all objects matching a specific IndexedQuery.
The type of objects to find.
The query to execute.
A list of objects matching the query.
Similar to IndexedStorage.find, but only returns the identifiers of the found objects.
The type of objects to find.
The query to execute.
A list of identifiers of the matching objects.
Protected
findFinds the IDs of all root objects that contain objects of the given type matching the given query by making use of the indexes applicable to the keys in the query. This function only looks at the keys in the query with primitive values, object values in the query referencing parent objects are not considered. Similarly, only indexes are used, keys without index are also ignored.
If an array of root IDs is provided as input, the result will be an intersection of this array and the found identifiers.
If the result is an empty array, it means that there is no valid identifier matching the query,
while an undefined
result means there is no index matching any of the query keys,
so a result can't be determined.
Optional
rootIds: string[]Returns the object of the given type with the given identifier.
The type of object to get.
The identifier of that object.
A representation of the object, or undefined
if there is no object of that type with that identifier.
Protected
getFinds all objects in the provided object that can be found by following the provided path of virtual keys.
Protected
getReturns all relations where the given type is the parent.
Protected
getFinds the record in the given object that contains the given type/id combination. This function assumes it was already verified through an index that this object contains the given combination.
Protected
getProtected
getReturns the relation where the given type is the child.
Will return undefined
for the root type as that one doesn't have a parent.
Protected
getFinds all records that can be found in the given object by following the given path of virtual keys.
Protected
getProtected
getFinds the root object that contains the requested type/id combination.
Sets the value of a specific object. The identifier in the object is used to identify the object.
The type of the object to set.
The new value for the object.
Protected
solveFinds all objects of the given type matching the query.
The rootIds
array can be used to restrict the IDs of root objects to look at,
which is relevant for the recursive calls the function does.
Will throw an error if there is no index that can be used to solve the query.
Optional
rootIds: string[]Protected
toConverts a VirtualObject into a TypeObject. To be used when outputting results.
Protected
updateUpdate all indexes for an object of the given type, and all its children.
Optional
newObj: VirtualObjectProtected
updateProtected
updateUpdates all indexes for an object of the given type.
Optional
oldObj: VirtualObjectOptional
newObj: VirtualObjectProtected
updateReplaces an object of the given type. The identifier in the value is used to determine which object.
Replaces part of an object of the given type with the given partial value. The identifier in the value is used to determine which object.
Protected
validateMakes sure the defined types fulfill all the requirements necessary for types on this storage. Will throw an error if this is not the case. This should be called before doing any data interactions. Stores success in a variable so future calls are instantaneous.
An IndexedStorage that makes use of 2 KeyValueStorages to implement the interface. Due to being limited by key/value storages, there are some restrictions on the allowed type definitions:
All of the above to create a tree-like structure of references. Such a tree is then stored in one of the storages. The other storage is used to store all indexes that are used to find the correct tree object when solving queries.