Skip to content

Commit

Permalink
fix rename mongodb functions
Browse files Browse the repository at this point in the history
  • Loading branch information
touv committed Aug 8, 2024
1 parent 86bf16e commit 0231ad2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/api/controller/api/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const restoreFields = (fileStream, ctx) => {
.then((fieldsString) => JSON.parse(fieldsString))
.then((fields) => {
ctx.field
.remove({})
.drop()
.then(() =>
Promise.all(
fields
Expand Down Expand Up @@ -70,7 +70,7 @@ export const restoreFields = (fileStream, ctx) => {
};

return ctx.field
.remove({})
.drop()
.then(restoreTask)
.then(() =>
Promise.all([
Expand Down Expand Up @@ -315,6 +315,7 @@ export const importFields = (asyncBusboyImpl) => async (ctx) => {
ctx.status = 200;
} catch (e) {
ctx.status = 500;
console.error(e);
ctx.body = e.message;
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/api/models/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const castIdsFactory = (collection) => async () => {
(acc, item) =>
acc.then(async () => {
await acc;
await collection.removeOne({ _id: item._id });
await collection.deleteOne({ _id: item._id });
await collection.insertOne({
...item,
_id: new ObjectId(item._id),
Expand Down
6 changes: 3 additions & 3 deletions src/api/services/clearPublished.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export default async (ctx, triggeredFromPublication) => {
{ multi: true },
);
progress.incrementProgress(ctx.tenant, 25);
await ctx.publishedDataset.remove({});
await ctx.publishedDataset.drop();
progress.incrementProgress(ctx.tenant, 25);
await ctx.publishedCharacteristic.remove({});
await ctx.publishedCharacteristic.drop();
progress.incrementProgress(ctx.tenant, 25);
await ctx.publishedFacet.remove({});
await ctx.publishedFacet.drop();
progress.finish(ctx.tenant);
};
4 changes: 2 additions & 2 deletions src/api/services/updateFacetValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ const removeOldValue = (publishedFacet, field) => async (oldValue) => {
);

if (updatedFacet.count <= 0) {
await publishedFacet.remove(updatedFacet);
await publishedFacet.deleteOne(updatedFacet);
}
};

const addNewValue = (publishedFacet, field) => async (newValue) => {
await publishedFacet.update(
await publishedFacet.updateOne(
{ field, value: newValue },
{ $inc: { count: 1 } },
{ upsert: true },
Expand Down

0 comments on commit 0231ad2

Please sign in to comment.