mongoose 6.3.2 → 6.3.5
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/README.md +1 -1
- package/dist/browser.umd.js +1 -1
- package/lib/cast/objectid.js +3 -2
- package/lib/connection.js +1 -1
- package/lib/document.js +53 -47
- package/lib/error/index.js +2 -2
- package/lib/helpers/clone.js +9 -2
- package/lib/helpers/common.js +3 -4
- package/lib/helpers/discriminator/areDiscriminatorValuesEqual.js +2 -2
- package/lib/helpers/isBsonType.js +5 -3
- package/lib/helpers/model/castBulkWrite.js +12 -0
- package/lib/helpers/path/setDottedPath.js +14 -1
- package/lib/helpers/query/cast$expr.js +4 -1
- package/lib/helpers/topology/isAtlas.js +15 -2
- package/lib/index.js +2 -2
- package/lib/model.js +42 -57
- package/lib/query.js +5 -2
- package/lib/queryhelpers.js +3 -2
- package/lib/schema/decimal128.js +4 -4
- package/lib/schema/string.js +2 -1
- package/lib/schema.js +9 -0
- package/lib/types/DocumentArray/methods/index.js +3 -3
- package/lib/types/array/methods/index.js +3 -3
- package/lib/types/map.js +4 -4
- package/lib/utils.js +7 -4
- package/package.json +24 -4
- package/types/aggregate.d.ts +3 -4
- package/types/callback.d.ts +8 -0
- package/types/collection.d.ts +46 -0
- package/types/connection.d.ts +92 -72
- package/types/document.d.ts +5 -5
- package/types/error.d.ts +5 -1
- package/types/helpers.d.ts +33 -0
- package/types/index.d.ts +20 -1856
- package/types/indizes.d.ts +98 -0
- package/types/middlewares.d.ts +14 -0
- package/types/models.d.ts +419 -0
- package/types/populate.d.ts +40 -0
- package/types/query.d.ts +637 -0
- package/types/schematypes.d.ts +418 -0
- package/types/session.d.ts +36 -0
- package/types/types.d.ts +102 -0
- package/types/utility.d.ts +13 -0
- package/types/validation.d.ts +32 -0
package/types/document.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ declare module 'mongoose' {
|
|
|
68
68
|
* automatically set `session` if you `save()` a doc that you got from a
|
|
69
69
|
* query with an associated session.
|
|
70
70
|
*/
|
|
71
|
-
$session(session?:
|
|
71
|
+
$session(session?: ClientSession | null): ClientSession | null;
|
|
72
72
|
|
|
73
73
|
/** Alias for `set()`, used internally to avoid conflicts */
|
|
74
74
|
$set(path: string, val: any, type: any, options?: any): this;
|
|
@@ -221,11 +221,11 @@ declare module 'mongoose' {
|
|
|
221
221
|
set(value: any): this;
|
|
222
222
|
|
|
223
223
|
/** The return value of this method is used in calls to JSON.stringify(doc). */
|
|
224
|
-
toJSON<T = DocType
|
|
225
|
-
toJSON<T = DocType
|
|
224
|
+
toJSON<T = LeanDocument<DocType>>(options?: ToObjectOptions & { flattenMaps?: true }): FlattenMaps<T>;
|
|
225
|
+
toJSON<T = LeanDocument<DocType>>(options: ToObjectOptions & { flattenMaps: false }): T;
|
|
226
226
|
|
|
227
227
|
/** Converts this document into a plain-old JavaScript object ([POJO](https://masteringjs.io/tutorials/fundamentals/pojo)). */
|
|
228
|
-
toObject<T = DocType
|
|
228
|
+
toObject<T = LeanDocument<DocType>>(options?: ToObjectOptions): Require_id<T>;
|
|
229
229
|
|
|
230
230
|
/** Clears the modified state on the specified path. */
|
|
231
231
|
unmarkModified(path: string): void;
|
|
@@ -247,4 +247,4 @@ declare module 'mongoose' {
|
|
|
247
247
|
validateSync(options: { pathsToSkip?: pathsToSkip, [k: string]: any }): Error.ValidationError | null;
|
|
248
248
|
validateSync(pathsToValidate?: pathsToValidate, options?: AnyObject): Error.ValidationError | null;
|
|
249
249
|
}
|
|
250
|
-
}
|
|
250
|
+
}
|
package/types/error.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ declare class NativeError extends global.Error { }
|
|
|
3
3
|
declare module 'mongoose' {
|
|
4
4
|
import mongodb = require('mongodb');
|
|
5
5
|
|
|
6
|
-
type
|
|
6
|
+
type CastError = Error.CastError;
|
|
7
|
+
type SyncIndexesError = Error.SyncIndexesError;
|
|
7
8
|
|
|
8
9
|
class MongooseError extends global.Error {
|
|
9
10
|
constructor(msg: string);
|
|
@@ -16,7 +17,10 @@ declare module 'mongoose' {
|
|
|
16
17
|
static Messages: any;
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
class Error extends MongooseError { }
|
|
21
|
+
|
|
19
22
|
namespace Error {
|
|
23
|
+
|
|
20
24
|
export class CastError extends MongooseError {
|
|
21
25
|
name: 'CastError';
|
|
22
26
|
stringValue: string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
declare module 'mongoose' {
|
|
2
|
+
import mongodb = require('mongodb');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mongoose uses this function to get the current time when setting
|
|
6
|
+
* [timestamps](/docs/guide.html#timestamps). You may stub out this function
|
|
7
|
+
* using a tool like [Sinon](https://www.npmjs.com/package/sinon) for testing.
|
|
8
|
+
*/
|
|
9
|
+
function now(): NativeDate;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Tells `sanitizeFilter()` to skip the given object when filtering out potential query selector injection attacks.
|
|
13
|
+
* Use this method when you have a known query selector that you want to use.
|
|
14
|
+
*/
|
|
15
|
+
function trusted<T>(obj: T): T;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Returns true if the given value is a Mongoose ObjectId (using `instanceof`) or if the
|
|
19
|
+
* given value is a 24 character hex string, which is the most commonly used string representation
|
|
20
|
+
* of an ObjectId.
|
|
21
|
+
*/
|
|
22
|
+
function isObjectIdOrHexString(v: mongodb.ObjectId): true;
|
|
23
|
+
function isObjectIdOrHexString(v: string): boolean;
|
|
24
|
+
function isObjectIdOrHexString(v: any): false;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Returns true if Mongoose can cast the given value to an ObjectId, or
|
|
28
|
+
* false otherwise.
|
|
29
|
+
*/
|
|
30
|
+
function isValidObjectId(v: mongodb.ObjectId): true;
|
|
31
|
+
function isValidObjectId(v: Types.ObjectId): true;
|
|
32
|
+
function isValidObjectId(v: any): boolean;
|
|
33
|
+
}
|