mongoose 7.2.2 → 7.2.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.
package/lib/connection.js CHANGED
@@ -975,7 +975,9 @@ function _setClient(conn, client, options, dbName) {
975
975
  }
976
976
 
977
977
  /**
978
- * Destory the connection (not just a alias of [`.close`](https://mongoosejs.com/docs/api/connection.html#Connection.prototype.close()))
978
+ * Destroy the connection. Similar to [`.close`](https://mongoosejs.com/docs/api/connection.html#Connection.prototype.close()),
979
+ * but also removes the connection from Mongoose's `connections` list and prevents the
980
+ * connection from ever being re-opened.
979
981
  *
980
982
  * @param {Boolean} [force]
981
983
  * @returns {Promise}
package/lib/model.js CHANGED
@@ -2812,19 +2812,27 @@ Model.create = async function create(doc, options) {
2812
2812
  } else {
2813
2813
  const last = arguments[arguments.length - 1];
2814
2814
  options = {};
2815
- if (typeof last === 'function' || (arguments.length > 1 && !last)) {
2816
- if (typeof options === 'function' ||
2817
- typeof arguments[2] === 'function') {
2818
- throw new MongooseError('Model.create() no longer accepts a callback');
2819
- }
2815
+ const hasCallback = typeof last === 'function' ||
2816
+ typeof options === 'function' ||
2817
+ typeof arguments[2] === 'function';
2818
+ if (hasCallback) {
2819
+ throw new MongooseError('Model.create() no longer accepts a callback');
2820
2820
  } else {
2821
2821
  args = [...arguments];
2822
+ // For backwards compatibility with 6.x, because of gh-5061 Mongoose 6.x and
2823
+ // older would treat a falsy last arg as a callback. We don't want to throw
2824
+ // an error here, because it would look strange if `Test.create({}, void 0)`
2825
+ // threw a callback error. But we also don't want to create an unnecessary document.
2826
+ if (args.length > 1 && !last) {
2827
+ args.pop();
2828
+ }
2822
2829
  }
2823
2830
 
2824
2831
  if (args.length === 2 &&
2825
2832
  args[0] != null &&
2826
2833
  args[1] != null &&
2827
2834
  args[0].session == null &&
2835
+ last &&
2828
2836
  getConstructorName(last.session) === 'ClientSession' &&
2829
2837
  !this.schema.path('session')) {
2830
2838
  // Probably means the user is running into the common mistake of trying
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mongoose",
3
3
  "description": "Mongoose MongoDB ODM",
4
- "version": "7.2.2",
4
+ "version": "7.2.3",
5
5
  "author": "Guillermo Rauch <guillermo@learnboost.com>",
6
6
  "keywords": [
7
7
  "mongodb",
@@ -28,10 +28,10 @@
28
28
  "sift": "16.0.1"
29
29
  },
30
30
  "devDependencies": {
31
- "@babel/core": "7.21.8",
32
- "@babel/preset-env": "7.21.5",
33
- "@typescript-eslint/eslint-plugin": "5.59.2",
34
- "@typescript-eslint/parser": "5.59.2",
31
+ "@babel/core": "7.22.1",
32
+ "@babel/preset-env": "7.22.4",
33
+ "@typescript-eslint/eslint-plugin": "5.59.8",
34
+ "@typescript-eslint/parser": "5.59.8",
35
35
  "acquit": "1.3.0",
36
36
  "acquit-ignore": "0.2.1",
37
37
  "acquit-require": "0.1.1",
@@ -44,9 +44,9 @@
44
44
  "buffer": "^5.6.0",
45
45
  "cheerio": "1.0.0-rc.12",
46
46
  "crypto-browserify": "3.12.0",
47
- "dotenv": "16.0.3",
47
+ "dotenv": "16.1.3",
48
48
  "dox": "1.0.0",
49
- "eslint": "8.39.0",
49
+ "eslint": "8.41.0",
50
50
  "eslint-plugin-markdown": "^3.0.0",
51
51
  "eslint-plugin-mocha-no-only": "1.1.1",
52
52
  "express": "^4.18.1",
@@ -62,12 +62,12 @@
62
62
  "nyc": "15.1.0",
63
63
  "pug": "3.0.2",
64
64
  "q": "1.5.1",
65
- "sinon": "15.0.4",
65
+ "sinon": "15.1.0",
66
66
  "stream-browserify": "3.0.0",
67
67
  "tsd": "0.28.1",
68
- "typescript": "5.0.4",
68
+ "typescript": "5.1.3",
69
69
  "uuid": "9.0.0",
70
- "webpack": "5.81.0",
70
+ "webpack": "5.85.0",
71
71
  "fs-extra": "~11.1.1"
72
72
  },
73
73
  "directories": {
@@ -1793,7 +1793,7 @@ declare module 'mongoose' {
1793
1793
  * @version 3.6
1794
1794
  * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/#mongodb-expression-exp.-mergeObjects
1795
1795
  */
1796
- $mergeObjects: ObjectExpression | ObjectExpression[] | ArrayExpression;
1796
+ $mergeObjects: ObjectExpression | ObjectExpression[] | ArrayExpression | Record<string, string>;
1797
1797
  }
1798
1798
 
1799
1799
  export interface SetField {
package/types/types.d.ts CHANGED
@@ -42,7 +42,7 @@ declare module 'mongoose' {
42
42
  shift(): T;
43
43
 
44
44
  /** Returns a native js Array. */
45
- toObject(options?: ToObjectOptions<T>): any;
45
+ toObject(options?: ToObjectOptions): any;
46
46
  toObject<T>(options?: ToObjectOptions<T>): T;
47
47
 
48
48
  /** Wraps [`Array#unshift`](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/unshift) with proper change tracking. */