diff --git a/src/api/controller/api/field.js b/src/api/controller/api/field.js index 4ad3d6c00..61ca39967 100644 --- a/src/api/controller/api/field.js +++ b/src/api/controller/api/field.js @@ -35,7 +35,7 @@ export const restoreFields = (fileStream, ctx) => { .then((fieldsString) => JSON.parse(fieldsString)) .then((fields) => { ctx.field - .remove({}) + .drop() .then(() => Promise.all( fields @@ -70,7 +70,7 @@ export const restoreFields = (fileStream, ctx) => { }; return ctx.field - .remove({}) + .drop() .then(restoreTask) .then(() => Promise.all([ @@ -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; } }; diff --git a/src/api/models/utils.js b/src/api/models/utils.js index 2b962c7d8..3a2866075 100644 --- a/src/api/models/utils.js +++ b/src/api/models/utils.js @@ -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), diff --git a/src/api/services/clearPublished.js b/src/api/services/clearPublished.js index 4ec97b319..e99b3ef7c 100644 --- a/src/api/services/clearPublished.js +++ b/src/api/services/clearPublished.js @@ -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); }; diff --git a/src/api/services/updateFacetValue.js b/src/api/services/updateFacetValue.js index 0675c91ca..80e3b0ab5 100644 --- a/src/api/services/updateFacetValue.js +++ b/src/api/services/updateFacetValue.js @@ -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 },