mongoose 8.19.2 → 8.19.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -72,7 +72,7 @@ module.exports = function getIndexes(schema) {
72
72
  if (index !== false && index !== null && index !== undefined) {
73
73
  const field = {};
74
74
  const isObject = helperIsObject(index);
75
- const options = isObject ? index : {};
75
+ const options = isObject ? { ...index } : {};
76
76
  const type = typeof index === 'string' ? index :
77
77
  isObject ? index.type :
78
78
  false;
package/lib/model.js CHANGED
@@ -802,8 +802,18 @@ Model.prototype.deleteOne = function deleteOne(options) {
802
802
  }
803
803
  }
804
804
 
805
- query.pre(function queryPreDeleteOne(cb) {
806
- self.constructor._middleware.execPre('deleteOne', self, [self], cb);
805
+ query.pre(async function queryPreDeleteOne() {
806
+ await new Promise((resolve, reject) => {
807
+ self.constructor._middleware.execPre('deleteOne', self, [self], err => {
808
+ if (err) reject(err);
809
+ else resolve();
810
+ });
811
+ });
812
+ // Apply custom where conditions _after_ document deleteOne middleware for
813
+ // consistency with save() - sharding plugin needs to set $where
814
+ if (self.$where != null) {
815
+ this.where(self.$where);
816
+ }
807
817
  });
808
818
  query.pre(function callSubdocPreHooks(cb) {
809
819
  each(self.$getAllSubdocs(), (subdoc, cb) => {
@@ -16,7 +16,7 @@ module.exports = function shardingPlugin(schema) {
16
16
  applyWhere.call(this);
17
17
  next();
18
18
  });
19
- schema.pre('remove', function shardingPluginPreRemove(next) {
19
+ schema.pre('deleteOne', { document: true, query: false }, function shardingPluginPreRemove(next) {
20
20
  applyWhere.call(this);
21
21
  next();
22
22
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mongoose",
3
3
  "description": "Mongoose MongoDB ODM",
4
- "version": "8.19.2",
4
+ "version": "8.19.3",
5
5
  "author": "Guillermo Rauch <guillermo@learnboost.com>",
6
6
  "keywords": [
7
7
  "mongodb",
@@ -29,10 +29,10 @@
29
29
  "sift": "17.1.3"
30
30
  },
31
31
  "devDependencies": {
32
- "@ark/attest": "0.48.2",
33
- "@babel/core": "7.28.4",
34
- "@babel/preset-env": "7.28.3",
35
- "@mongodb-js/mongodb-downloader": "^0.4.2",
32
+ "@ark/attest": "0.53.0",
33
+ "@babel/core": "7.28.5",
34
+ "@babel/preset-env": "7.28.5",
35
+ "@mongodb-js/mongodb-downloader": "^1.0.0",
36
36
  "@typescript-eslint/eslint-plugin": "^8.19.1",
37
37
  "@typescript-eslint/parser": "^8.19.1",
38
38
  "acquit": "1.4.0",
@@ -55,12 +55,12 @@
55
55
  "lodash.isequal": "4.5.0",
56
56
  "lodash.isequalwith": "4.4.0",
57
57
  "markdownlint-cli2": "^0.18.1",
58
- "marked": "15.0.12",
58
+ "marked": "16.4.1",
59
59
  "mkdirp": "^3.0.1",
60
60
  "mocha": "11.7.4",
61
61
  "moment": "2.30.1",
62
- "mongodb-memory-server": "10.2.1",
63
- "mongodb-runner": "^5.8.2",
62
+ "mongodb-memory-server": "10.3.0",
63
+ "mongodb-runner": "^6.0.0",
64
64
  "ncp": "^2.0.0",
65
65
  "nyc": "15.1.0",
66
66
  "pug": "3.0.3",
@@ -70,7 +70,7 @@
70
70
  "tsd": "0.33.0",
71
71
  "typescript": "5.9.3",
72
72
  "uuid": "11.1.0",
73
- "webpack": "5.102.0"
73
+ "webpack": "5.102.1"
74
74
  },
75
75
  "directories": {
76
76
  "lib": "./lib/mongoose"
@@ -60,7 +60,7 @@ declare module 'mongoose' {
60
60
  [PathValueType] extends [neverOrAny] ? PathValueType
61
61
  : PathValueType extends Schema ? InferSchemaType<PathValueType>
62
62
  : PathValueType extends ReadonlyArray<infer Item> ?
63
- Item extends never ? any[]
63
+ [Item] extends [never] ? any[]
64
64
  : Item extends Schema ?
65
65
  // If Item is a schema, infer its type.
66
66
  Array<InferSchemaType<Item>>