Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IDbNoSqlOperations

Defines NoSQL operations on Coaty objects.

Hierarchy

Implemented by

Index

Methods

addCollection

  • addCollection(name: string): Promise<void>
  • Add a new collection with the given name if it doesn't exist.

    Returns a promise that is fulfilled if the operation succeeded. The promise is rejected if an error occurred.

    Parameters

    • name: string

    Returns Promise<void>

aggregateObjects

  • Aggregates values of the given object property in the collection for objects which match the given filter. Depending on the aggregation operator specified either numeric or boolean values are yielded. The value type of the given object property must match the aggregation operator specified.

    If the filter is empty or not specified all objects are considered for aggregation. If the filter matches no objects at all the aggregated value returned is undefined. Returns a promise that if fulfilled yields the aggregated value of matching object properties. The promise is rejected if an error occurred.

    The object property to be applied for aggregation is specified either in dot notation or array notation. In dot notation, the name of the object property is specified as a string (e.g. "volume"). It may include dots (.) to access nested properties of subobjects (e.g. "message.size"). If a single property name contains dots itself, you obviously cannot use dot notation. Instead, specify the property or nested properties as an array of strings (e.g. ["property.with.dots", "subproperty.with.dots"]).

    Parameters

    Returns Promise<number | boolean>

clearCollection

  • clearCollection(name: string): Promise<void>
  • Clear all objects from the collection with the given name.

    Returns a promise that is fulfilled if the operation succeeded. The promise is rejected if an error occurred.

    Parameters

    • name: string

    Returns Promise<void>

countObjects

  • countObjects(collectionName: string, filter?: DbObjectFilter): Promise<number>
  • Counts objects in the collection which match the given filter. If the filter is empty or not specified counts the total number of objects in the collection. Returns a promise that if fulfilled yields the number of matching objects. The promise is rejected if an error occurred.

    Parameters

    Returns Promise<number>

deleteObjects

  • deleteObjects(collectionName: string, filter?: DbObjectFilter): Promise<number>
  • Deletes objects from the collection which match the given filter. If the filter is empty or not specified all objects in the collection are deleted. Returns a promise that if fulfilled yields the number of objects deleted. The promise is rejected if an error occurred. In this case it is guaranteed that none of the requested objects has been deleted.

    Parameters

    Returns Promise<number>

deleteObjectsById

  • deleteObjectsById(collectionName: string, objectIds: string | string[]): Promise<string[]>
  • Deletes an object or multiple objects with the given object IDs from the collection. Objects which are not contained in the collection are ignored. Returns a promise that if fulfilled yields an array of object IDs of deleted objects. The promise is rejected if an error occurred. In this case it is guaranteed that none of the requested objects has been deleted.

    Parameters

    • collectionName: string
    • objectIds: string | string[]

    Returns Promise<string[]>

findObjectById

  • findObjectById<T>(collectionName: string, id: string, isExternalId?: boolean): Promise<T>
  • Finds the first object with the given object ID or external ID in the collection. Returns a promise that if fulfilled yields the first found object or undefined if no object with the given ID is contained in the collection. The promise is rejected if an error occurred.

    If the isExternalId parameter is not specified, the given id is interpreted as object ID.

    Type parameters

    Parameters

    • collectionName: string
    • id: string
    • Optional isExternalId: boolean

    Returns Promise<T>

findObjects

  • Finds objects in the collection which match the given object filter. If the filter is empty or not specified all objects in the collection are retrieved.

    Optional join conditions can be specified to augment result objects by resolving object references to related objects and storing them as extra properties.

    The result can be iterated one by one or in batches to avoid memory overrun when the result contains a large number of objects.

    Returns a promise that if fulfilled yields an iterator for iterating the resulting objects. The promise is rejected if an error occurred.

    Type parameters

    Parameters

    Returns Promise<IQueryIterator<T>>

insertObjects

  • insertObjects(collectionName: string, objects: CoatyObject | CoatyObject[], shouldReplaceExisting?: boolean): Promise<string[]>
  • Inserts a single object or multiple objects into the specified collection. If an object with the same object ID is already contained in the collection, the object to be inserted can be skipped or can replace the existing one, depending on the shouldReplaceExisting option (defaults to true).

    If no error occurs a fullfilled promise is returned that yields an array of object IDs of inserted or replaced objects. Otherwise, a rejected promise is returned. In this case, it is guaranteed that none of the specified objects has been inserted into the collection.

    Parameters

    Returns Promise<string[]>

removeCollection

  • removeCollection(name: string): Promise<void>
  • Remove the collection with the given name if it exists.

    Returns a promise that is fulfilled if the operation succeeded. The promise is rejected if an error occurred.

    Parameters

    • name: string

    Returns Promise<void>

updateObjectProperty

  • updateObjectProperty(collectionName: string, objectIds: string | string[], property: string, value: any, shouldCreateMissing?: boolean): Promise<any>
  • Updates or deletes the property value of a single object or multiple objects with the given object IDs in the specified collection. Objects which are not contained in the collection are ignored. The shouldCreateMissing parameter controls whether the property value pair is added to an object if the property does not exist (defaults to true). Specify an undefined value to delete the property value pair from the object(s).

    Returns a promise that is resolved if the update is successful. The promise is rejected if an error occurred. In this case it is guaranteed that none of the objects has been updated.

    Parameters

    • collectionName: string
    • objectIds: string | string[]
    • property: string
    • value: any
    • Optional shouldCreateMissing: boolean

    Returns Promise<any>

updateObjects

  • Updates a single object or multiple objects on the specified collection. If an object with the same object ID is not contained in the collection, this object is ignored.

    Returns a promise that if fulfilled yields an array of object IDs of updated objects. The promise is rejected if an error occurred. In this case it is guaranteed that none of the objects has been updated.

    Parameters

    Returns Promise<string[]>

Generated using TypeDoc