MemoryTable.getItem()method
Get an item by its id, or undefined if it doesn't exist.
getItem(id: I): OptionalItem<I, T>
new MemoryTable<I, T>(collection: Collection<string, I, T>)
| Param | Type | |
|---|---|---|
collection | Collection<string, I, T> | Collection this table holds the items of. required |
| Return | |
|---|---|
MemoryTable<I, T> | In-memory table holding the items of a single collection for a MemoryDBProvider. |
| Property | Type | |
|---|---|---|
.next | unknown | Deferred sequence that resolves on every change to this table. Defaults to new DeferredSequence() readonly |
.collection | Collection<string, I, T> | Collection this table stores the items of. required readonly |
In-memory table holding the items of a single collection for a MemoryDBProvider.
Map, preserving the exact object instance passed in.next DeferredSequence that resolves on every change, powering the live *Sequence subscriptions.const table = provider.getTable(users);
table.setItem(123, { name: "Dave" });Get an item by its id, or undefined if it doesn't exist.
getItem(id: I): OptionalItem<I, T>
Subscribe to all changes for this item key.
getItemSequence(id: I): AsyncIterable<OptionalItem<I, T>>
Generate a unique id for a new item in this table.
generateUniqueID(): I
Add a new item with a freshly generated unique id.
addItem(data: T): I
Set (insert or overwrite) an item by its id.
setItem(id: I, data: Item<I, T> | T): void
Mirror an async sequence of item values into this table, passing each value through.
setItemSequence(id: I, sequence: AsyncIterable<OptionalItem<I, T>>): AsyncIterable<OptionalItem<I, T>>
Apply partial updates to an existing item by its id.
updateItem(id: I, updates: Updates<Item<I, T>>): void
Delete an item by its id.
deleteItem(id: I): void
Count the items in this table matching an optional query.
countQuery(query?: Query<Item<I, T>>): number
Get the items in this table matching an optional query.
getQuery(query?: Query<Item<I, T>>): Items<I, T>
Subscribe to the live result of a query.
getQuerySequence(query?: Query<Item<I, T>>): AsyncIterable<Items<I, T>>
Set (overwrite) the data for every item matching a query.
setQuery(query: Query<Item<I, T>>, data: T): void
Apply partial updates to every item matching a query.
updateQuery(query: Query<Item<I, T>>, updates: Updates<T>): void
deleteQuery(query: Query<Item<I, T>>): void
setItems(items: Items<I, T>): void
setItemsSequence(sequence: AsyncIterable<Items<I, T>>): AsyncIterable<Items<I, T>>