Class: EntityStorageRestClient<T>
Client for performing entity storage through to REST endpoints.
Extends
BaseRestClient
Type Parameters
T
T
Implements
IEntityStorageComponent<T>
Constructors
Constructor
new EntityStorageRestClient<
T>(config):EntityStorageRestClient<T>
Create a new instance of EntityStorageRestClient.
Parameters
config
IBaseRestClientConfig
The configuration for the client.
Returns
EntityStorageRestClient<T>
Overrides
BaseRestClient.constructor
Properties
CLASS_NAME
readonlystaticCLASS_NAME:string
Runtime name for the class.
Methods
className()
className():
string
Returns the class name of the component.
Returns
string
The class name of the component.
Implementation of
IEntityStorageComponent.className
set()
set(
entity,conditions?):Promise<void>
Set an entity.
Parameters
entity
T
The entity to set.
conditions?
object[]
The optional conditions to match for the entities.
Returns
Promise<void>
The id of the entity.
Implementation of
IEntityStorageComponent.set
setBatch()
setBatch(
entities):Promise<void>
Set multiple entities in a batch.
Parameters
entities
T[]
The entities to set.
Returns
Promise<void>
Nothing.
Implementation of
IEntityStorageComponent.setBatch
get()
get(
id,secondaryIndex?,conditions?):Promise<T|undefined>
Get an entity.
Parameters
id
string
The id of the entity to get, or the index value if secondaryIndex is set.
secondaryIndex?
keyof T
Get the item using a secondary index.
conditions?
object[]
The optional conditions to match for the entities.
Returns
Promise<T | undefined>
The object if it can be found or undefined.
Implementation of
IEntityStorageComponent.get
remove()
remove(
id,conditions?):Promise<void>
Remove the entity.
Parameters
id
string
The id of the entity to remove.
conditions?
object[]
The optional conditions to match for the entities.
Returns
Promise<void>
Nothing.
Implementation of
IEntityStorageComponent.remove
removeBatch()
removeBatch(
ids):Promise<void>
Remove multiple entities by id.
Parameters
ids
string[]
The ids of the entities to remove.
Returns
Promise<void>
Nothing.
Implementation of
IEntityStorageComponent.removeBatch
empty()
empty():
Promise<void>
Remove all entities from the storage.
Returns
Promise<void>
Nothing.
Implementation of
IEntityStorageComponent.empty
count()
count(
conditions?):Promise<number>
Count all the entities which match the conditions.
Parameters
conditions?
EntityCondition<T>
The optional conditions to match for the entities.
Returns
Promise<number>
The total count of entities in the storage.
Implementation of
IEntityStorageComponent.count
query()
query(
conditions?,orderBy?,orderByDirection?,properties?,cursor?,limit?):Promise<{entities:Partial<T>[];cursor?:string; }>
Query all the entities which match the conditions.
Parameters
conditions?
EntityCondition<T>
The conditions to match for the entities.
orderBy?
keyof T
The order for the results.
orderByDirection?
SortDirection
The direction for the order, defaults to ascending.
properties?
keyof T[]
The optional properties to return, defaults to all.
cursor?
string
The cursor to request the next chunk of entities.
limit?
number
The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
Returns
Promise<{ entities: Partial<T>[]; cursor?: string; }>
All the entities for the storage matching the conditions, and a cursor which can be used to request more entities.
Implementation of
IEntityStorageComponent.query