Skip to content

Commit

Permalink
unset record 'id' so mongodb doesn't try to use is as an objectid (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
cofiem authored Jan 22, 2025
1 parent cbd460e commit 5a21c29
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions typescript/api/services/MongoStorageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ export module Services {
_.unset(record, 'dateCreated');
_.unset(record, 'lastSaveDate');
_.unset(record, '_id');

// Records with an 'id' property fail to save with error:
// {"cause":{"name":"AdapterError","adapterMethodName":"update","modelIdentity":"record","raw":{"code":"E_CANNOT_INTERPRET_AS_OBJECTID"}},"isOperational":true}
// Fix by ensuring the 'id' property is removed.
_.unset(record, 'id');

await Record.updateOne({ redboxOid: oid }).set(record);
response.success = true;
} catch (err) {
Expand Down

0 comments on commit 5a21c29

Please sign in to comment.