mongoose 8.6.1 → 8.6.2

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
@@ -71,6 +71,9 @@ function Connection(base) {
71
71
  } else {
72
72
  this.id = base.nextConnectionId;
73
73
  }
74
+
75
+ // Internal queue of objects `{ fn, ctx, args }` that Mongoose calls when this connection is successfully
76
+ // opened. In `onOpen()`, Mongoose calls every entry in `_queue` and empties the queue.
74
77
  this._queue = [];
75
78
  }
76
79
 
@@ -10,7 +10,7 @@ const eachAsync = require('../helpers/cursor/eachAsync');
10
10
  const helpers = require('../queryHelpers');
11
11
  const kareem = require('kareem');
12
12
  const immediate = require('../helpers/immediate');
13
- const { once } = require('node:events');
13
+ const { once } = require('events');
14
14
  const util = require('util');
15
15
 
16
16
  /**
package/lib/document.js CHANGED
@@ -1213,7 +1213,7 @@ Document.prototype.$set = function $set(path, val, type, options) {
1213
1213
  this.$__setValue(path, null);
1214
1214
  cleanModifiedSubpaths(this, path);
1215
1215
  } else {
1216
- return this.$set(val, path, constructing);
1216
+ return this.$set(val, path, constructing, options);
1217
1217
  }
1218
1218
 
1219
1219
  const keys = getKeysInSchemaOrder(this.$__schema, val, path);
@@ -96,7 +96,7 @@ NativeConnection.prototype.useDb = function(name, options) {
96
96
  if (this.db && this._readyState === STATES.connected) {
97
97
  wireup();
98
98
  } else {
99
- this.once('connected', wireup);
99
+ this._queue.push({ fn: wireup });
100
100
  }
101
101
 
102
102
  function wireup() {
@@ -27,13 +27,6 @@ module.exports = function trackTransaction(schema) {
27
27
  initialState.atomics = _getAtomics(this);
28
28
 
29
29
  session[sessionNewDocuments].set(this, initialState);
30
- } else {
31
- const state = session[sessionNewDocuments].get(this);
32
-
33
- for (const path of Object.keys(this.$__.activePaths.getStatePaths('modify'))) {
34
- state.modifiedPaths.add(path);
35
- }
36
- state.atomics = _getAtomics(this, state.atomics);
37
30
  }
38
31
  });
39
32
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mongoose",
3
3
  "description": "Mongoose MongoDB ODM",
4
- "version": "8.6.1",
4
+ "version": "8.6.2",
5
5
  "author": "Guillermo Rauch <guillermo@learnboost.com>",
6
6
  "keywords": [
7
7
  "mongodb",
package/types/cursor.d.ts CHANGED
@@ -8,6 +8,7 @@ declare module 'mongoose' {
8
8
  parallel?: number;
9
9
  batchSize?: number;
10
10
  continueOnError?: boolean;
11
+ signal?: AbortSignal;
11
12
  }
12
13
 
13
14
  class Cursor<DocType = any, Options = never> extends stream.Readable {
@@ -91,8 +91,8 @@ declare module 'mongoose' {
91
91
  IfEquals<PathValueType, String> extends true ? PathEnumOrString<Options['enum']> :
92
92
  PathValueType extends NumberSchemaDefinition ? Options['enum'] extends ReadonlyArray<any> ? Options['enum'][number] : number :
93
93
  IfEquals<PathValueType, Schema.Types.Number> extends true ? number :
94
- PathValueType extends DateSchemaDefinition ? Date :
95
- IfEquals<PathValueType, Schema.Types.Date> extends true ? Date :
94
+ PathValueType extends DateSchemaDefinition ? NativeDate :
95
+ IfEquals<PathValueType, Schema.Types.Date> extends true ? NativeDate :
96
96
  PathValueType extends typeof Buffer | 'buffer' | 'Buffer' | typeof Schema.Types.Buffer ? Buffer :
97
97
  PathValueType extends BooleanSchemaDefinition ? boolean :
98
98
  IfEquals<PathValueType, Schema.Types.Boolean> extends true ? boolean :
@@ -281,8 +281,8 @@ type ResolvePathType<PathValueType, Options extends SchemaTypeOptions<PathValueT
281
281
  IfEquals<PathValueType, String> extends true ? PathEnumOrString<Options['enum']> :
282
282
  PathValueType extends NumberSchemaDefinition ? Options['enum'] extends ReadonlyArray<any> ? Options['enum'][number] : number :
283
283
  IfEquals<PathValueType, Schema.Types.Number> extends true ? number :
284
- PathValueType extends DateSchemaDefinition ? Date :
285
- IfEquals<PathValueType, Schema.Types.Date> extends true ? Date :
284
+ PathValueType extends DateSchemaDefinition ? NativeDate :
285
+ IfEquals<PathValueType, Schema.Types.Date> extends true ? NativeDate :
286
286
  PathValueType extends typeof Buffer | 'buffer' | 'Buffer' | typeof Schema.Types.Buffer ? Buffer :
287
287
  PathValueType extends BooleanSchemaDefinition ? boolean :
288
288
  IfEquals<PathValueType, Schema.Types.Boolean> extends true ? boolean :
package/types/query.d.ts CHANGED
@@ -12,7 +12,7 @@ declare module 'mongoose' {
12
12
  */
13
13
  type RootFilterQuery<T> = FilterQuery<T> | Query<any, any> | Types.ObjectId;
14
14
 
15
- type FilterQuery<T> ={
15
+ type FilterQuery<T> = {
16
16
  [P in keyof T]?: Condition<T[P]>;
17
17
  } & RootQuerySelector<T> & { _id?: Condition<string>; };
18
18
 
@@ -117,10 +117,8 @@ declare module 'mongoose' {
117
117
  /** @see https://www.mongodb.com/docs/manual/reference/operator/query/comment/#op._S_comment */
118
118
  $comment?: string;
119
119
  $expr?: Record<string, any>;
120
- // we could not find a proper TypeScript generic to support nested queries e.g. 'user.friends.name'
121
- // this will mark all unrecognized properties as any (including nested queries) only if
122
- // they include a "." (to avoid generically allowing any unexpected keys)
123
- [nestedSelector: `${string}.${string}`]: any;
120
+ // this will mark all unrecognized properties as any (including nested queries)
121
+ [key: string]: any;
124
122
  };
125
123
 
126
124
  interface QueryTimestampsConfig {
@@ -216,6 +216,9 @@ declare module 'mongoose' {
216
216
  /** Attaches a getter for all instances of this schema type. */
217
217
  static get(getter: (value: any) => any): void;
218
218
 
219
+ /** Array containing default setters for all instances of this SchemaType */
220
+ static setters: ((val?: unknown, priorVal?: unknown, doc?: Document<unknown>, options?: Record<string, any> | null) => unknown)[];
221
+
219
222
  /** The class that Mongoose uses internally to instantiate this SchemaType's `options` property. */
220
223
  OptionsConstructor: SchemaTypeOptions<T>;
221
224