ItemStoreclass
new ItemStore<I, T>(collection: Collection<string, I, T>, id: I, provider: DBProvider<I>, memory?: MemoryDBProvider<I>)
| Param | Type | |
|---|---|---|
collection | Collection<string, I, T> | The collection the item lives in. required |
id | I | The ID of the item to track. required |
provider | DBProvider<I> | The database provider to fetch the item from. required |
memory | MemoryDBProvider<I> | Optional memory provider used to seed the initial value and drive realtime updates. |
| Return | |
|---|---|
ItemStore<I, T> | Store that fetches and tracks a single item by ID in a collection from a database provider. |
| Property | Type | |
|---|---|---|
.provider | DBProvider<I> | The database provider this store fetches its item from. required readonly |
.collection | Collection<string, I, T> | The collection the item lives in. required readonly |
.id | I | The ID of the item this store tracks. required readonly |
.item | Item<I, T> | The required item data of this store. - Use this when the item is known to exist; use value when it may be undefined. required |
Store that fetches and tracks a single item by ID in a collection from a database provider.
- Holds an
OptionalItemvalue: the item if it exists, orundefinedif it doesn't. - Seeds from a
MemoryDBProvidersnapshot when available, and subscribes to realtime updates.
Examples
const store = new ItemStore(collection, "abc", provider); const item = await store; // OptionalItem<I, T>