diff --git a/src/api/controller/api/field.js b/src/api/controller/api/field.js index d34c175ed..4ad3d6c00 100644 --- a/src/api/controller/api/field.js +++ b/src/api/controller/api/field.js @@ -20,7 +20,7 @@ import { } from '../../../common/scope'; import { dropJobs } from '../../workers/tools'; import { ENRICHER } from '../../workers/enricher'; -import { ObjectID } from 'mongodb'; +import { ObjectId } from 'mongodb'; import generateUid from '../../services/generateUid'; import { restoreEnrichments } from '../../services/enrichment/enrichment'; import { restorePrecomputed } from '../../services/precomputed/precomputed'; @@ -228,7 +228,7 @@ export const patchSearchableFields = async (ctx) => { const fields = ctx.request.body; try { - const ids = fields.map((field) => new ObjectID(field._id)); + const ids = fields.map((field) => new ObjectId(field._id)); await ctx.field.updateMany( { _id: { $in: ids } }, { $set: { searchable: true } }, diff --git a/src/api/controller/api/publishedDataset.js b/src/api/controller/api/publishedDataset.js index 62fb12e6b..a98345466 100644 --- a/src/api/controller/api/publishedDataset.js +++ b/src/api/controller/api/publishedDataset.js @@ -6,7 +6,7 @@ import { PROPOSED } from '../../../common/propositionStatus'; import generateUri from '../../../common/transformers/AUTOGENERATE_URI'; import ark from './ark'; import updateFacetValue from '../../services/updateFacetValue'; -import { ObjectID } from 'mongodb'; +import { ObjectId } from 'mongodb'; const app = new Koa(); @@ -29,7 +29,7 @@ export const getPage = async (ctx) => { const facetValues = await Promise.all( facetValueIds.map(async (facetValueId) => { const facetValue = await ctx.publishedFacet.findOne({ - _id: new ObjectID(facetValueId), + _id: new ObjectId(facetValueId), }); return facetValue.value; }), diff --git a/src/api/models/dataset.js b/src/api/models/dataset.js index e6ff38ca3..f8bed8ab3 100644 --- a/src/api/models/dataset.js +++ b/src/api/models/dataset.js @@ -4,7 +4,7 @@ import omit from 'lodash/omit'; import uniqWith from 'lodash/uniqWith'; import JSONStream from 'jsonstream'; import { Transform } from 'stream'; -import { ObjectID } from 'mongodb'; +import { ObjectId } from 'mongodb'; import { URI_FIELD_NAME, moveUriToFirstPosition } from '../../common/uris'; import countNotUnique from './countNotUnique'; @@ -201,7 +201,7 @@ export default (db) => { }; collection.deleteOne = async (id) => - collection.deleteOne({ _id: new ObjectID(id) }); + collection.deleteOne({ _id: new ObjectId(id) }); return collection; }; diff --git a/src/api/models/field.js b/src/api/models/field.js index c73935645..b0d44c734 100644 --- a/src/api/models/field.js +++ b/src/api/models/field.js @@ -1,6 +1,6 @@ import omit from 'lodash/omit'; import pick from 'lodash/pick'; -import { ObjectID, ObjectId } from 'mongodb'; +import { ObjectId } from 'mongodb'; import { validateField as validateFieldIsomorphic } from '../../common/validateFields'; import { URI_FIELD_NAME } from '../../common/uris'; @@ -120,7 +120,7 @@ export default async (db) => { }; collection.findOneById = (id) => - collection.findOne({ _id: new ObjectID(id) }); + collection.findOne({ _id: new ObjectId(id) }); collection.findOneByName = (name) => collection.findOne({ name }); @@ -154,13 +154,13 @@ export default async (db) => { }; collection.updateOneById = async (id, field) => { - const objectId = new ObjectID(id); + const objId = new ObjectId(id); const previousFieldVersion = await collection.findOneById(id); if (previousFieldVersion.position > field.position) { await collection.updateMany( { - _id: { $ne: objectId }, + _id: { $ne: objId }, position: { $gte: field.position, $lt: previousFieldVersion.position, @@ -175,7 +175,7 @@ export default async (db) => { if (previousFieldVersion.position < field.position) { await collection.updateMany( { - _id: { $ne: objectId }, + _id: { $ne: objId }, position: { $gt: previousFieldVersion.position, $lte: field.position, @@ -190,7 +190,7 @@ export default async (db) => { return collection .findOneAndUpdate( { - _id: objectId, + _id: objId, }, { $set: omit(field, ['_id']), @@ -203,12 +203,12 @@ export default async (db) => { }; collection.removeById = (id) => - collection.deleteOne({ _id: new ObjectID(id), name: { $ne: 'uri' } }); + collection.deleteOne({ _id: new ObjectId(id), name: { $ne: 'uri' } }); collection.removeBySubresource = (subresourceId) => collection.deleteOne({ $or: [ - { subresourceId: new ObjectID(subresourceId) }, + { subresourceId: new ObjectId(subresourceId) }, { subresourceId }, ], }); diff --git a/src/api/models/hiddenResource.js b/src/api/models/hiddenResource.js index 7b973df58..6b5a871df 100644 --- a/src/api/models/hiddenResource.js +++ b/src/api/models/hiddenResource.js @@ -1,4 +1,4 @@ -import { ObjectID } from 'mongodb'; +import { ObjectId } from 'mongodb'; import { castIdsFactory } from './utils'; export default async (db) => { @@ -18,7 +18,7 @@ export default async (db) => { collection.deleteByUri = async (uri) => collection.deleteOne({ uri }); collection.delete = async (id) => - collection.deleteOne({ _id: new ObjectID(id) }); + collection.deleteOne({ _id: new ObjectId(id) }); collection.castIds = castIdsFactory(collection); diff --git a/src/api/models/publishedDataset.js b/src/api/models/publishedDataset.js index 8871cce74..7eb5ad473 100644 --- a/src/api/models/publishedDataset.js +++ b/src/api/models/publishedDataset.js @@ -1,4 +1,4 @@ -import { ObjectID } from 'mongodb'; +import { ObjectId } from 'mongodb'; import chunk from 'lodash/chunk'; import omit from 'lodash/omit'; @@ -201,7 +201,7 @@ export default async (db) => { }; collection.findById = async (id) => { - const oid = new ObjectID(id); + const oid = new ObjectId(id); return collection.findOne({ _id: oid }); }; diff --git a/src/api/models/subresource.js b/src/api/models/subresource.js index 525451778..e06b3c87b 100644 --- a/src/api/models/subresource.js +++ b/src/api/models/subresource.js @@ -1,4 +1,4 @@ -import { ObjectID } from 'mongodb'; +import { ObjectId } from 'mongodb'; import omit from 'lodash/omit'; import { castIdsFactory } from './utils'; @@ -6,7 +6,7 @@ export default async (db) => { const collection = db.collection('subresource'); collection.findOneById = async (id) => - collection.findOne({ _id: new ObjectID(id) }); + collection.findOne({ _id: new ObjectId(id) }); collection.findAll = async () => collection.find({}).toArray(); @@ -16,15 +16,15 @@ export default async (db) => { }; collection.delete = async (id) => - collection.deleteOne({ _id: new ObjectID(id) }); + collection.deleteOne({ _id: new ObjectId(id) }); collection.update = async (id, data) => { - const objectId = new ObjectID(id); + const objId = new ObjectId(id); return collection .findOneAndUpdate( { - _id: objectId, + _id: objId, }, { $set: omit(data, ['_id']), diff --git a/src/api/models/tenant.js b/src/api/models/tenant.js index b5f990c16..a952e68b5 100644 --- a/src/api/models/tenant.js +++ b/src/api/models/tenant.js @@ -1,4 +1,4 @@ -import { ObjectID } from 'mongodb'; +import { ObjectId } from 'mongodb'; import omit from 'lodash/omit'; import { castIdsFactory } from './utils'; @@ -6,7 +6,7 @@ export default async (db) => { const collection = db.collection('tenant'); collection.findOneById = async (id) => - collection.findOne({ $or: [{ _id: new ObjectID(id) }, { _id: id }] }); + collection.findOne({ $or: [{ _id: new ObjectId(id) }, { _id: id }] }); collection.findOneByName = async (name) => collection.findOne({ name }); @@ -20,15 +20,15 @@ export default async (db) => { }; collection.delete = async (id) => - collection.deleteOne({ $or: [{ _id: new ObjectID(id) }, { _id: id }] }); + collection.deleteOne({ $or: [{ _id: new ObjectId(id) }, { _id: id }] }); collection.update = async (id, data) => { - const objectId = new ObjectID(id); + const objId = new ObjectId(id); return collection .findOneAndUpdate( { - $or: [{ _id: objectId }, { _id: id }], + $or: [{ _id: objId }, { _id: id }], }, { $set: omit(data, ['_id']), diff --git a/src/api/models/utils.js b/src/api/models/utils.js index 52b3672ec..2b962c7d8 100644 --- a/src/api/models/utils.js +++ b/src/api/models/utils.js @@ -1,4 +1,4 @@ -import { ObjectID } from 'mongodb'; +import { ObjectId } from 'mongodb'; export const castIdsFactory = (collection) => async () => { const items = await collection.find({}).toArray(); @@ -10,7 +10,7 @@ export const castIdsFactory = (collection) => async () => { await collection.removeOne({ _id: item._id }); await collection.insertOne({ ...item, - _id: new ObjectID(item._id), + _id: new ObjectId(item._id), }); }), Promise.resolve(),