Skip to content

Commit 89f691f

Browse files
committed
fix: add check for id
1 parent 7e0ecfe commit 89f691f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/mongo/src/MongoDbCollection.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ export class MongoDbCollection implements IDatabaseCollection {
4949
data = data.toJSON();
5050
}
5151

52+
if (!("id" in oldDoc)) {
53+
throw new Error("Patching is not supported for documents with an 'id' field. Use 'update' instead.");
54+
}
55+
5256
const patch = jsonpatch.compare(oldDoc, data);
5357
const filter = { id: oldDoc.id };
5458

0 commit comments

Comments
 (0)