mongoose 6.3.0 → 6.3.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.
Files changed (42) hide show
  1. package/.eslintrc.json +157 -157
  2. package/README.md +2 -2
  3. package/dist/browser.umd.js +1 -1
  4. package/lib/collection.js +0 -7
  5. package/lib/connection.js +2 -1
  6. package/lib/document.js +65 -68
  7. package/lib/error/cast.js +8 -2
  8. package/lib/helpers/common.js +0 -8
  9. package/lib/helpers/immediate.js +3 -1
  10. package/lib/helpers/isAsyncFunction.js +19 -7
  11. package/lib/helpers/model/castBulkWrite.js +12 -0
  12. package/lib/helpers/populate/getModelsMapForPopulate.js +13 -10
  13. package/lib/helpers/query/cast$expr.js +4 -1
  14. package/lib/helpers/schematype/handleImmutable.js +4 -1
  15. package/lib/helpers/timestamps/setupTimestamps.js +2 -2
  16. package/lib/index.js +1 -1
  17. package/lib/internal.js +0 -1
  18. package/lib/model.js +42 -28
  19. package/lib/query.js +7 -3
  20. package/lib/queryhelpers.js +11 -1
  21. package/lib/schema/SubdocumentPath.js +3 -15
  22. package/lib/schema/documentarray.js +7 -7
  23. package/lib/schema/number.js +1 -5
  24. package/lib/schema/objectid.js +2 -4
  25. package/lib/schema/string.js +3 -6
  26. package/lib/schema.js +1 -1
  27. package/lib/schematype.js +2 -2
  28. package/lib/types/DocumentArray/methods/index.js +9 -1
  29. package/lib/types/array/methods/index.js +8 -9
  30. package/lib/utils.js +4 -0
  31. package/package.json +39 -19
  32. package/tsconfig.json +2 -2
  33. package/types/aggregate.d.ts +1 -2
  34. package/types/connection.d.ts +4 -5
  35. package/types/cursor.d.ts +3 -2
  36. package/types/document.d.ts +18 -15
  37. package/types/error.d.ts +124 -124
  38. package/types/index.d.ts +182 -154
  39. package/types/mongooseoptions.d.ts +1 -2
  40. package/types/schemaoptions.d.ts +1 -2
  41. package/CHANGELOG.md +0 -7249
  42. package/History.md +0 -1
package/types/error.d.ts CHANGED
@@ -1,129 +1,129 @@
1
- import mongodb = require('mongodb');
1
+ declare class NativeError extends global.Error { }
2
2
 
3
3
  declare module 'mongoose' {
4
+ import mongodb = require('mongodb');
4
5
 
5
- class NativeError extends global.Error { }
6
- type CallbackError = NativeError | null;
7
-
8
- class MongooseError extends global.Error {
9
- constructor(msg: string);
10
-
11
- /** The type of error. "MongooseError" for generic errors. */
12
- name: string;
13
-
14
- static messages: any;
15
-
16
- static Messages: any;
17
- }
18
-
19
- namespace Error {
20
- export class CastError extends MongooseError {
21
- name: 'CastError';
22
- stringValue: string;
23
- kind: string;
24
- value: any;
25
- path: string;
26
- reason?: NativeError | null;
27
- model?: any;
28
-
29
- constructor(type: string, value: any, path: string, reason?: NativeError, schemaType?: SchemaType);
30
- }
31
- export class SyncIndexesError extends MongooseError {
32
- name: 'SyncIndexesError';
33
- errors?: Record<string, mongodb.MongoServerError>;
34
-
35
- constructor(type: string, value: any, path: string, reason?: NativeError, schemaType?: SchemaType);
36
- }
37
-
38
- export class DisconnectedError extends MongooseError {
39
- name: 'DisconnectedError';
40
- }
41
-
42
- export class DivergentArrayError extends MongooseError {
43
- name: 'DivergentArrayError';
44
- }
45
-
46
- export class MissingSchemaError extends MongooseError {
47
- name: 'MissingSchemaError';
48
- }
49
-
50
- export class DocumentNotFoundError extends MongooseError {
51
- name: 'DocumentNotFoundError';
52
- result: any;
53
- numAffected: number;
54
- filter: any;
55
- query: any;
56
- }
57
-
58
- export class ObjectExpectedError extends MongooseError {
59
- name: 'ObjectExpectedError';
60
- path: string;
61
- }
62
-
63
- export class ObjectParameterError extends MongooseError {
64
- name: 'ObjectParameterError';
65
- }
66
-
67
- export class OverwriteModelError extends MongooseError {
68
- name: 'OverwriteModelError';
69
- }
70
-
71
- export class ParallelSaveError extends MongooseError {
72
- name: 'ParallelSaveError';
73
- }
74
-
75
- export class ParallelValidateError extends MongooseError {
76
- name: 'ParallelValidateError';
77
- }
78
-
79
- export class MongooseServerSelectionError extends MongooseError {
80
- name: 'MongooseServerSelectionError';
81
- }
82
-
83
- export class StrictModeError extends MongooseError {
84
- name: 'StrictModeError';
85
- isImmutableError: boolean;
86
- path: string;
87
- }
88
-
89
- export class ValidationError extends MongooseError {
90
- name: 'ValidationError';
91
-
92
- errors: { [path: string]: ValidatorError | CastError };
93
- addError: (path: string, error: ValidatorError | CastError) => void;
94
-
95
- constructor(instance?: MongooseError);
96
- }
97
-
98
- export class ValidatorError extends MongooseError {
99
- name: 'ValidatorError';
100
- properties: {
101
- message: string,
102
- type?: string,
103
- path?: string,
104
- value?: any,
105
- reason?: any
106
- };
107
- kind: string;
108
- path: string;
109
- value: any;
110
- reason?: MongooseError | null;
111
-
112
- constructor(properties: {
113
- message?: string,
114
- type?: string,
115
- path?: string,
116
- value?: any,
117
- reason?: any
118
- });
119
- }
120
-
121
- export class VersionError extends MongooseError {
122
- name: 'VersionError';
123
- version: number;
124
- modifiedPaths: Array<string>;
125
-
126
- constructor(doc: Document, currentVersion: number, modifiedPaths: Array<string>);
127
- }
6
+ type CallbackError = NativeError | null;
7
+
8
+ class MongooseError extends global.Error {
9
+ constructor(msg: string);
10
+
11
+ /** The type of error. "MongooseError" for generic errors. */
12
+ name: string;
13
+
14
+ static messages: any;
15
+
16
+ static Messages: any;
17
+ }
18
+
19
+ namespace Error {
20
+ export class CastError extends MongooseError {
21
+ name: 'CastError';
22
+ stringValue: string;
23
+ kind: string;
24
+ value: any;
25
+ path: string;
26
+ reason?: NativeError | null;
27
+ model?: any;
28
+
29
+ constructor(type: string, value: any, path: string, reason?: NativeError, schemaType?: SchemaType);
30
+ }
31
+ export class SyncIndexesError extends MongooseError {
32
+ name: 'SyncIndexesError';
33
+ errors?: Record<string, mongodb.MongoServerError>;
34
+
35
+ constructor(type: string, value: any, path: string, reason?: NativeError, schemaType?: SchemaType);
36
+ }
37
+
38
+ export class DisconnectedError extends MongooseError {
39
+ name: 'DisconnectedError';
40
+ }
41
+
42
+ export class DivergentArrayError extends MongooseError {
43
+ name: 'DivergentArrayError';
44
+ }
45
+
46
+ export class MissingSchemaError extends MongooseError {
47
+ name: 'MissingSchemaError';
48
+ }
49
+
50
+ export class DocumentNotFoundError extends MongooseError {
51
+ name: 'DocumentNotFoundError';
52
+ result: any;
53
+ numAffected: number;
54
+ filter: any;
55
+ query: any;
56
+ }
57
+
58
+ export class ObjectExpectedError extends MongooseError {
59
+ name: 'ObjectExpectedError';
60
+ path: string;
61
+ }
62
+
63
+ export class ObjectParameterError extends MongooseError {
64
+ name: 'ObjectParameterError';
65
+ }
66
+
67
+ export class OverwriteModelError extends MongooseError {
68
+ name: 'OverwriteModelError';
69
+ }
70
+
71
+ export class ParallelSaveError extends MongooseError {
72
+ name: 'ParallelSaveError';
73
+ }
74
+
75
+ export class ParallelValidateError extends MongooseError {
76
+ name: 'ParallelValidateError';
77
+ }
78
+
79
+ export class MongooseServerSelectionError extends MongooseError {
80
+ name: 'MongooseServerSelectionError';
81
+ }
82
+
83
+ export class StrictModeError extends MongooseError {
84
+ name: 'StrictModeError';
85
+ isImmutableError: boolean;
86
+ path: string;
87
+ }
88
+
89
+ export class ValidationError extends MongooseError {
90
+ name: 'ValidationError';
91
+
92
+ errors: { [path: string]: ValidatorError | CastError };
93
+ addError: (path: string, error: ValidatorError | CastError) => void;
94
+
95
+ constructor(instance?: MongooseError);
96
+ }
97
+
98
+ export class ValidatorError extends MongooseError {
99
+ name: 'ValidatorError';
100
+ properties: {
101
+ message: string,
102
+ type?: string,
103
+ path?: string,
104
+ value?: any,
105
+ reason?: any
106
+ };
107
+ kind: string;
108
+ path: string;
109
+ value: any;
110
+ reason?: MongooseError | null;
111
+
112
+ constructor(properties: {
113
+ message?: string,
114
+ type?: string,
115
+ path?: string,
116
+ value?: any,
117
+ reason?: any
118
+ });
119
+ }
120
+
121
+ export class VersionError extends MongooseError {
122
+ name: 'VersionError';
123
+ version: number;
124
+ modifiedPaths: Array<string>;
125
+
126
+ constructor(doc: Document, currentVersion: number, modifiedPaths: Array<string>);
128
127
  }
128
+ }
129
129
  }