Private
Readonly
indexPrivate
Readonly
indexesFor every type, the keys on which an index tracks the values and which root object they are contained in.
All types for which a defineType
call was made will have a key in this object.
For all types that are not the root, there will always be an index on their ID value.
Protected
Readonly
loggerPrivate
Readonly
relationsAll parent/child relations between all types in the storage, including the keys in both types that are used to reference each other.
Private
rootThe variable in which the root type is stored.
A separate getter is used to always return the value
so the potential undefined
does not have to be taken into account.
Private
validKeeps track of type validation. If true the defined types create a valid structure that can be used.
Private
Readonly
valueProtected
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.
The type to create an index on.
The key of that type to create an index on.
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.
The type to define.
A description of the values stored in objects of that type.
Deletes the given object. This will also delete all objects that reference that object if the corresponding key is not optional.
The type of the object to delete.
The identifier of the object.
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.
Sets the value of one specific field in an object.
The type of the object to update.
The identifier of the object to update.
The key to update.
The new value for the given key.
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.