From 61d73b1f598eaa82d1dfc22242c819af7c5ef620 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 30 Jul 2024 17:26:49 +0200 Subject: [PATCH] Add createdAd and updatedAt on bulkDocs --- packages/backend-core/src/db/couch/DatabaseImpl.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/backend-core/src/db/couch/DatabaseImpl.ts b/packages/backend-core/src/db/couch/DatabaseImpl.ts index feeba6061e..61fbb3d61e 100644 --- a/packages/backend-core/src/db/couch/DatabaseImpl.ts +++ b/packages/backend-core/src/db/couch/DatabaseImpl.ts @@ -308,8 +308,12 @@ export class DatabaseImpl implements Database { } async bulkDocs(documents: AnyDocument[]) { + const now = new Date().toISOString() return this.performCall(db => { - return () => db.bulk({ docs: documents }) + return () => + db.bulk({ + docs: documents.map(d => ({ createdAt: now, ...d, updatedAt: now })), + }) }) }