diff --git a/package-lock.json b/package-lock.json index e8ed85b3f..6b6c014c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,7 @@ "luxon": "^3.2.1", "mathjs": "^12.0.0", "migrate-mongo": "^11.0.0", - "mongoose": "^8.3.1", + "mongoose": "^8.4.0", "node-fetch": "^3.3.0", "nodemailer": "^6.7.8", "openid-client": "^5.1.8", @@ -4606,9 +4606,9 @@ } }, "node_modules/bson": { - "version": "6.6.0", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.6.0.tgz", - "integrity": "sha512-BVINv2SgcMjL4oYbBuCQTpE3/VKOSxrOA8Cj/wQP7izSzlBGVomdm+TcUd0Pzy0ytLSSDweCKQ6X3f5veM5LQA==", + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.7.0.tgz", + "integrity": "sha512-w2IquM5mYzYZv6rs3uN2DZTOBe2a0zXLj53TGDqwF4l6Sz/XsISrisXOJihArF9+BZ6Cq/GjVht7Sjfmri7ytQ==", "engines": { "node": ">=16.20.1" } @@ -10670,12 +10670,12 @@ } }, "node_modules/mongodb": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.5.0.tgz", - "integrity": "sha512-Fozq68InT+JKABGLqctgtb8P56pRrJFkbhW0ux+x1mdHeyinor8oNzJqwLjV/t5X5nJGfTlluxfyMnOXNggIUA==", + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.6.2.tgz", + "integrity": "sha512-ZF9Ugo2JCG/GfR7DEb4ypfyJJyiKbg5qBYKRintebj8+DNS33CyGMkWbrS9lara+u+h+yEOGSRiLhFO/g1s1aw==", "dependencies": { "@mongodb-js/saslprep": "^1.1.5", - "bson": "^6.4.0", + "bson": "^6.7.0", "mongodb-connection-string-url": "^3.0.0" }, "engines": { @@ -10755,17 +10755,17 @@ } }, "node_modules/mongoose": { - "version": "8.3.1", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.3.1.tgz", - "integrity": "sha512-D78C+s7QI4+pJQhs3XbOxzrHFEti4x+BDhaH94QrdV1/cmMA7fHc50LgLSXjzA/5q89TBK8DAXyf3VwDZbQJlA==", + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.4.0.tgz", + "integrity": "sha512-fgqRMwVEP1qgRYfh+tUe2YBBFnPO35FIg2lfFH+w9IhRGg1/ataWGIqvf/MjwM29cZ60D5vSnqtN2b8Qp0sOZA==", "dependencies": { - "bson": "^6.5.0", + "bson": "^6.7.0", "kareem": "2.6.3", - "mongodb": "6.5.0", + "mongodb": "6.6.2", "mpath": "0.9.0", "mquery": "5.0.0", "ms": "2.1.3", - "sift": "16.0.1" + "sift": "17.1.3" }, "engines": { "node": ">=16.20.1" @@ -12686,9 +12686,9 @@ } }, "node_modules/sift": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/sift/-/sift-16.0.1.tgz", - "integrity": "sha512-Wv6BjQ5zbhW7VFefWusVP33T/EM0vYikCaQ2qR8yULbsilAT8/wQaXvuQ3ptGLpoKx+lihJE3y2UTgKDyyNHZQ==" + "version": "17.1.3", + "resolved": "https://registry.npmjs.org/sift/-/sift-17.1.3.tgz", + "integrity": "sha512-Rtlj66/b0ICeFzYTuNvX/EF1igRbbnGSvEyT79McoZa/DeGhMyC5pWKOEsZKnpkqtSeovd5FL/bjHWC3CIIvCQ==" }, "node_modules/signal-exit": { "version": "4.1.0", diff --git a/package.json b/package.json index b8e3e0457..65b1ff50f 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "luxon": "^3.2.1", "mathjs": "^12.0.0", "migrate-mongo": "^11.0.0", - "mongoose": "^8.3.1", + "mongoose": "^8.4.0", "node-fetch": "^3.3.0", "nodemailer": "^6.7.8", "openid-client": "^5.1.8", diff --git a/src/datasets/datasets.service.ts b/src/datasets/datasets.service.ts index c13edd355..c78974c1e 100644 --- a/src/datasets/datasets.service.ts +++ b/src/datasets/datasets.service.ts @@ -64,10 +64,8 @@ export class DatasetsService { // insert created and updated fields addCreatedByFields(createDatasetDto, username), ); - if (this.ESClient) { - await this.ESClient.updateInsertDocument( - createdDataset.toObject() as DatasetDocument, - ); + if (this.ESClient && createdDataset) { + await this.ESClient.updateInsertDocument(createdDataset.toObject()); } return createdDataset.save(); } @@ -242,10 +240,8 @@ export class DatasetsService { throw new NotFoundException(`Dataset #${id} not found`); } - if (this.ESClient) { - await this.ESClient.updateInsertDocument( - updatedDataset.toObject() as DatasetDocument, - ); + if (this.ESClient && updatedDataset) { + await this.ESClient.updateInsertDocument(updatedDataset.toObject()); } // we were able to find the dataset and update it return updatedDataset; @@ -283,10 +279,8 @@ export class DatasetsService { ) .exec(); - if (this.ESClient) { - await this.ESClient.updateInsertDocument( - patchedDataset?.toObject() as DatasetDocument, - ); + if (this.ESClient && patchedDataset) { + await this.ESClient.updateInsertDocument(patchedDataset.toObject()); } // we were able to find the dataset and update it diff --git a/src/elastic-search/elastic-search.service.ts b/src/elastic-search/elastic-search.service.ts index fc3dca187..69782558b 100644 --- a/src/elastic-search/elastic-search.service.ts +++ b/src/elastic-search/elastic-search.service.ts @@ -359,7 +359,7 @@ export class ElasticSearchService implements OnModuleInit { ); } } - async updateInsertDocument(data: DatasetDocument) { + async updateInsertDocument(data: Partial) { //NOTE: Replace all keys with lower case, also replace spaces and dot with underscore delete data._id; const transformedScientificMetadata = transformKeysInObject(