diff --git a/packages/reference/src/collection-reference.ts b/packages/reference/src/collection-reference.ts index daaaa409..979d7ad9 100644 --- a/packages/reference/src/collection-reference.ts +++ b/packages/reference/src/collection-reference.ts @@ -13,7 +13,7 @@ import {waitForImmediate, waitForTimeout} from '@alwatr/wait'; import {logger} from './logger.js'; import {getStoreId, getStorePath} from './util.js'; -import type {Dictionary, JsonifiableObject} from '@alwatr/type-helper'; +import type {Dictionary, JsonObject} from '@alwatr/type-helper'; logger.logModule?.('collection-reference'); @@ -23,7 +23,7 @@ logger.logModule?.('collection-reference'); * * @template TItem - The data type of the collection items. */ -export class CollectionReference { +export class CollectionReference { /** * Alwatr store engine version string. */ @@ -43,7 +43,7 @@ export class CollectionReference( + static newRefFromData( stat: StoreFileId, initialData: CollectionContext['data'] | null, updatedCallback: (from: CollectionReference) => void, @@ -79,7 +79,7 @@ export class CollectionReference( + static newRefFromContext( context: CollectionContext, updatedCallback: (from: CollectionReference) => void, debugDomain?: string, @@ -147,7 +147,7 @@ export class CollectionReference { - this.logger__.logMethodArgs?.('updated__', {id, immediate, delayed: this.updateDelayed_}); + private async updated__(itemId: string | number | null = null, immediate = false): Promise { + this.logger__.logMethodArgs?.('updated__', {id: itemId, immediate, delayed: this.updateDelayed_}); this.hasUnprocessedChanges_ = true; - if (id !== null) this.refreshMeta_(id); // meta must updated per item + if (itemId !== null) this.refreshMeta_(itemId); // meta must updated per item if (immediate === false && this.updateDelayed_ === true) return; // else @@ -597,7 +597,7 @@ export class CollectionReference { +export class DocumentReference { /** * Alwatr store engine version string. */ @@ -33,7 +33,7 @@ export class DocumentReference( + static newRefFromData( statId: StoreFileId, initialData: TDoc, updatedCallback: (from: DocumentReference) => unknown, @@ -68,7 +68,7 @@ export class DocumentReference( + static newRefFromContext( context: DocumentContext, updatedCallback: (from: DocumentReference) => unknown, debugDomain?: string, @@ -136,7 +136,7 @@ export class DocumentReference