Skip to content

Commit 242fd59

Browse files
ggazzoclaude
andcommitted
fix(models): call setUpdatedAt for all docs in insertMany
insertMany() only called setUpdatedAt() when a document already had a valid _id. Documents without _id (the common case) got an _id generated but skipped setUpdatedAt(), leaving them without _updatedAt in the database. This caused API response validation failures for endpoints using $ref schemas that require _updatedAt (e.g. subscriptions.getOne). Align insertMany() with insertOne(), which already calls setUpdatedAt() unconditionally. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 2e6441e commit 242fd59

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/models/src/models/BaseRaw.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export abstract class BaseRaw<
274274
docs = docs.map((doc) => {
275275
if (!doc._id || typeof doc._id !== 'string') {
276276
const oid = new ObjectId();
277-
return { _id: oid.toHexString(), ...doc };
277+
doc = { _id: oid.toHexString(), ...doc };
278278
}
279279
this.setUpdatedAt(doc);
280280
return doc;

0 commit comments

Comments
 (0)