Skip to content

Commit

Permalink
feat(reference): enhance logging
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd committed Dec 28, 2023
1 parent 63edd08 commit 4eab5a2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/reference/src/collection-reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ export class CollectionReference<TItem extends Dictionary = Dictionary> {
* ```
*/
update(id: string | number, data: Partial<TItem>): void {
this.logger__.logMethodArgs?.('update', data);
this.logger__.logMethodArgs?.('update', {id, data});
Object.assign(this.item__(id).data, data);
this.updated__(id);
}
Expand Down Expand Up @@ -400,6 +400,7 @@ export class CollectionReference<TItem extends Dictionary = Dictionary> {
* ```
*/
keys(): string[] {
this.logger__.logMethod?.('keys');
return Object.keys(this.context__.data);
}

Expand All @@ -416,6 +417,7 @@ export class CollectionReference<TItem extends Dictionary = Dictionary> {
* ```
*/
values(): CollectionItem<TItem>[] {
this.logger__.logMethod?.('values');
return Object.values(this.context__.data);
}

Expand All @@ -432,6 +434,7 @@ export class CollectionReference<TItem extends Dictionary = Dictionary> {
* ```
*/
*ids(): Generator<string, void, void> {
this.logger__.logMethod?.('ids');
for (const id in this.context__.data) {
yield id;
}
Expand All @@ -449,6 +452,7 @@ export class CollectionReference<TItem extends Dictionary = Dictionary> {
* }
*/
*items(): Generator<CollectionItem<TItem>, void, void> {
this.logger__.logMethod?.('items');
for (const id in this.context__.data) {
yield this.context__.data[id];
}
Expand Down Expand Up @@ -510,6 +514,7 @@ export class CollectionReference<TItem extends Dictionary = Dictionary> {
* ```
*/
private nextAutoIncrementId__(): number {
this.logger__.logMethod?.('nextAutoIncrementId__');
const meta = this.context__.meta as Required<StoreFileMeta>;
do {
meta.lastAutoId++;
Expand Down

0 comments on commit 4eab5a2

Please sign in to comment.