Skip to content

Commit

Permalink
fix: update initializeSubresourceModel to use atomics operators
Browse files Browse the repository at this point in the history
  • Loading branch information
AlasDiablo committed Oct 6, 2023
1 parent 2a033b3 commit f73a110
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/api/models/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,15 +323,22 @@ export default async db => {
collection.initializeSubresourceModel = async subresource => {
const newField = createSubresourceUriField(subresource);

await collection.updateOne(
{
name: `${subresource._id}_${URI_FIELD_NAME}`,
},
newField,
{
upsert: true,
},
);
try {
await collection.updateOne(
{
name: `${subresource._id}_${URI_FIELD_NAME}`,
},
{
$set: newField,
},
{
upsert: true,
},
);
} catch (e) {
console.error(e);
throw e;
}
};

collection.updateSubresourcePaths = async subresource => {
Expand Down

0 comments on commit f73a110

Please sign in to comment.