ItemStoreclass

new ItemStore<I, T>(collection: Collection<string, I, T>, id: I, provider: DBProvider<I>, memory?: MemoryDBProvider<I>)
ParamType
collectionCollection<string, I, T>
The collection the item lives in. required
idI
The ID of the item to track. required
providerDBProvider<I>
The database provider to fetch the item from. required
memoryMemoryDBProvider<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.
PropertyType
.providerDBProvider<I>
The database provider this store fetches its item from. required readonly
.collectionCollection<string, I, T>
The collection the item lives in. required readonly
.idI
The ID of the item this store tracks. required readonly
.itemItem<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 OptionalItem value: the item if it exists, or undefined if it doesn't.
  • Seeds from a MemoryDBProvider snapshot when available, and subscribes to realtime updates.

Examples

const store = new ItemStore(collection, "abc", provider);
 const item = await store; // OptionalItem<I, T>