Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set updateAt on records when updating a record #1272

Merged
merged 13 commits into from
Feb 10, 2023
Merged
4 changes: 4 additions & 0 deletions packages/core/src/storage/IndyStorageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ export class IndyStorageService<T extends BaseRecord<any, any, any>> implements
public async save(agentContext: AgentContext, record: T) {
assertIndyWallet(agentContext.wallet)

record.updatedAt = new Date()

const value = JsonTransformer.serialize(record)
const tags = this.transformFromRecordTagValues(record.getTags()) as Record<string, string>

Expand All @@ -157,6 +159,8 @@ export class IndyStorageService<T extends BaseRecord<any, any, any>> implements
public async update(agentContext: AgentContext, record: T): Promise<void> {
assertIndyWallet(agentContext.wallet)

record.updatedAt = new Date()

const value = JsonTransformer.serialize(record)
const tags = this.transformFromRecordTagValues(record.getTags()) as Record<string, string>

Expand Down
2 changes: 2 additions & 0 deletions tests/InMemoryStorageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class InMemoryStorageService<T extends BaseRecord = BaseRecord> implement

/** @inheritDoc */
public async save(agentContext: AgentContext, record: T) {
record.updatedAt = new Date()
const value = JsonTransformer.toJSON(record)

if (this.records[record.id]) {
Expand All @@ -51,6 +52,7 @@ export class InMemoryStorageService<T extends BaseRecord = BaseRecord> implement

/** @inheritDoc */
public async update(agentContext: AgentContext, record: T): Promise<void> {
record.updatedAt = new Date()
const value = JsonTransformer.toJSON(record)
delete value._tags

Expand Down