@kikiutils/mongoose 7.1.0 → 9.0.0
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 +8 -8
- package/dist/_internals.d.ts +4 -0
- package/dist/_internals.d.ts.map +1 -1
- package/dist/_internals.js +2 -1
- package/dist/_internals.js.map +1 -1
- package/dist/builders.d.ts +1 -3
- package/dist/builders.d.ts.map +1 -1
- package/dist/builders.js +8 -9
- package/dist/builders.js.map +1 -1
- package/dist/connection.d.ts +5 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +10 -0
- package/dist/connection.js.map +1 -0
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +2 -1
- package/dist/options.js.map +1 -1
- package/dist/plugins/lean-decimal128-to-string.d.ts +26 -0
- package/dist/plugins/lean-decimal128-to-string.d.ts.map +1 -0
- package/dist/plugins/lean-decimal128-to-string.js +85 -0
- package/dist/plugins/lean-decimal128-to-string.js.map +1 -0
- package/dist/plugins/normalize.d.ts +24 -14
- package/dist/plugins/normalize.d.ts.map +1 -1
- package/dist/plugins/normalize.js +20 -10
- package/dist/plugins/normalize.js.map +1 -1
- package/dist/schema-builders/base.d.ts +1 -1
- package/dist/schema-builders/base.d.ts.map +1 -1
- package/dist/schema-builders/base.js.map +1 -1
- package/dist/schema-builders/bigint.d.ts +60 -0
- package/dist/schema-builders/bigint.d.ts.map +1 -0
- package/dist/schema-builders/bigint.js +58 -0
- package/dist/schema-builders/bigint.js.map +1 -0
- package/dist/schema-builders/boolean.d.ts.map +1 -1
- package/dist/schema-builders/boolean.js.map +1 -1
- package/dist/schema-builders/date.d.ts +2 -2
- package/dist/schema-builders/date.d.ts.map +1 -1
- package/dist/schema-builders/date.js.map +1 -1
- package/dist/schema-builders/decimal128.d.ts +20 -14
- package/dist/schema-builders/decimal128.d.ts.map +1 -1
- package/dist/schema-builders/decimal128.js +1 -0
- package/dist/schema-builders/decimal128.js.map +1 -1
- package/dist/schema-builders/double.d.ts +60 -0
- package/dist/schema-builders/double.d.ts.map +1 -0
- package/dist/schema-builders/double.js +62 -0
- package/dist/schema-builders/double.js.map +1 -0
- package/dist/schema-builders/index.d.ts +6 -1
- package/dist/schema-builders/index.js +6 -1
- package/dist/schema-builders/int32.d.ts +60 -0
- package/dist/schema-builders/int32.d.ts.map +1 -0
- package/dist/schema-builders/int32.js +58 -0
- package/dist/schema-builders/int32.js.map +1 -0
- package/dist/schema-builders/mixed.d.ts +34 -0
- package/dist/schema-builders/mixed.d.ts.map +1 -0
- package/dist/schema-builders/mixed.js +8 -0
- package/dist/schema-builders/mixed.js.map +1 -0
- package/dist/schema-builders/number.d.ts +2 -2
- package/dist/schema-builders/number.d.ts.map +1 -1
- package/dist/schema-builders/number.js.map +1 -1
- package/dist/schema-builders/object-id.d.ts +2 -2
- package/dist/schema-builders/object-id.d.ts.map +1 -1
- package/dist/schema-builders/object-id.js.map +1 -1
- package/dist/schema-builders/ref.d.ts +2 -2
- package/dist/schema-builders/ref.d.ts.map +1 -1
- package/dist/schema-builders/ref.js.map +1 -1
- package/dist/schema-builders/string.d.ts +35 -25
- package/dist/schema-builders/string.d.ts.map +1 -1
- package/dist/schema-builders/string.js.map +1 -1
- package/dist/schema-builders/uuid.d.ts +34 -0
- package/dist/schema-builders/uuid.d.ts.map +1 -0
- package/dist/schema-builders/uuid.js +8 -0
- package/dist/schema-builders/uuid.js.map +1 -0
- package/dist/types/aggregate-paginate.d.ts +24 -8
- package/dist/types/aggregate-paginate.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/options.d.ts +9 -4
- package/dist/types/options.d.ts.map +1 -1
- package/dist/types/paginate.d.ts +6 -2
- package/dist/types/paginate.d.ts.map +1 -1
- package/package.json +17 -12
- package/src/_internals.ts +3 -0
- package/src/builders.ts +18 -32
- package/src/connection.ts +14 -0
- package/src/options.ts +8 -1
- package/src/plugins/lean-decimal128-to-string.ts +149 -0
- package/src/plugins/normalize.ts +39 -15
- package/src/schema-builders/base.ts +6 -1
- package/src/schema-builders/bigint.ts +190 -0
- package/src/schema-builders/boolean.ts +1 -4
- package/src/schema-builders/date.ts +2 -2
- package/src/schema-builders/decimal128.ts +21 -14
- package/src/schema-builders/double.ts +198 -0
- package/src/schema-builders/index.ts +15 -0
- package/src/schema-builders/int32.ts +191 -0
- package/src/schema-builders/mixed.ts +37 -0
- package/src/schema-builders/number.ts +2 -2
- package/src/schema-builders/object-id.ts +2 -2
- package/src/schema-builders/ref.ts +2 -2
- package/src/schema-builders/string.ts +35 -25
- package/src/schema-builders/uuid.ts +48 -0
- package/src/types/aggregate-paginate.ts +29 -8
- package/src/types/index.ts +0 -5
- package/src/types/options.ts +12 -3
- package/src/types/paginate.ts +6 -2
- package/dist/constants.d.ts +0 -5
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -6
- package/dist/constants.js.map +0 -1
- package/dist/helpers.d.ts +0 -5
- package/dist/helpers.d.ts.map +0 -1
- package/dist/helpers.js +0 -9
- package/dist/helpers.js.map +0 -1
- package/src/constants.ts +0 -3
- package/src/helpers.ts +0 -5
|
@@ -49,9 +49,13 @@ export interface AggregatePaginateOptions {
|
|
|
49
49
|
page?: number;
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* Whether to apply pagination to the aggregation results.
|
|
53
53
|
*
|
|
54
|
-
* @
|
|
54
|
+
* @remarks
|
|
55
|
+
* If `false`, the pagination plugin adds no pagination `$skip` or `$limit` stages. Existing pipeline stages
|
|
56
|
+
* still apply.
|
|
57
|
+
*
|
|
58
|
+
* @defaultValue `true`, unless overridden by plugin-wide defaults.
|
|
55
59
|
*/
|
|
56
60
|
pagination?: boolean;
|
|
57
61
|
sort?: object | string;
|
|
@@ -59,17 +63,34 @@ export interface AggregatePaginateOptions {
|
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
export interface AggregatePaginateQueryPopulateOptions {
|
|
62
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* The query conditions used to filter populated documents.
|
|
68
|
+
*/
|
|
63
69
|
match?: any;
|
|
64
|
-
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The model or model name used to populate the referenced documents.
|
|
73
|
+
*/
|
|
65
74
|
model?: Model<any> | string;
|
|
66
|
-
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The query options applied when retrieving populated documents, such as sorting and limits.
|
|
78
|
+
*/
|
|
67
79
|
options?: any;
|
|
68
|
-
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The path or space-delimited paths to populate.
|
|
83
|
+
*/
|
|
69
84
|
path: string;
|
|
70
|
-
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The nested population options applied to the populated documents.
|
|
88
|
+
*/
|
|
71
89
|
populate?: AggregatePaginateQueryPopulateOptions | AggregatePaginateQueryPopulateOptions[];
|
|
72
|
-
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The field projection used when retrieving populated documents.
|
|
93
|
+
*/
|
|
73
94
|
select?: any;
|
|
74
95
|
}
|
|
75
96
|
|
package/src/types/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
Connection,
|
|
3
2
|
HydratedDocument,
|
|
4
3
|
QueryWithHelpers,
|
|
5
4
|
Types,
|
|
@@ -55,7 +54,3 @@ export type SetFieldsToObjectId<T, K extends keyof T> = SetFieldType<T, K, Types
|
|
|
55
54
|
// @ts-expect-error Ignore this error.
|
|
56
55
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
57
56
|
export interface BaseMongooseModelStatics<RawDocType, InstanceMethodsAndOverrides = object, QueryHelpers = object> {}
|
|
58
|
-
|
|
59
|
-
export interface MongooseConnections {
|
|
60
|
-
default?: Connection;
|
|
61
|
-
}
|
package/src/types/options.ts
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
Connection,
|
|
3
|
+
ConnectOptions,
|
|
3
4
|
Schema,
|
|
4
5
|
SchemaTimestampsConfig,
|
|
5
6
|
} from 'mongoose';
|
|
6
7
|
|
|
8
|
+
import type { MongooseLeanDecimal128ToStringPluginOptions } from '../plugins/lean-decimal128-to-string';
|
|
7
9
|
import type { MongooseNormalizePluginOptions } from '../plugins/normalize';
|
|
8
10
|
|
|
9
11
|
import type { BaseMongoosePaginateModel } from './';
|
|
10
12
|
|
|
11
13
|
export interface BuildMongooseModelOptions {
|
|
12
14
|
connection?: Connection;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
plugins?: {
|
|
16
|
+
/** Register lean conversion for marked Decimal128 fields. Defaults to true. */
|
|
17
|
+
leanDecimal128ToString?: boolean | MongooseLeanDecimal128ToStringPluginOptions;
|
|
18
|
+
|
|
19
|
+
/** Register JSON normalization. Defaults to true; an object enables it with custom options. */
|
|
20
|
+
normalize?: boolean | MongooseNormalizePluginOptions;
|
|
21
|
+
};
|
|
22
|
+
|
|
16
23
|
timestamps?: boolean | SchemaTimestampsConfig;
|
|
17
24
|
}
|
|
18
25
|
|
|
@@ -30,4 +37,6 @@ export interface CustomMongooseOptions {
|
|
|
30
37
|
QueryHelpers
|
|
31
38
|
>,
|
|
32
39
|
) => void;
|
|
40
|
+
|
|
41
|
+
defaultConnectionOptions?: ConnectOptions;
|
|
33
42
|
}
|
package/src/types/paginate.ts
CHANGED
|
@@ -91,9 +91,13 @@ export interface PaginateOptions {
|
|
|
91
91
|
page?: number;
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
|
-
*
|
|
94
|
+
* Whether to apply pagination to the query results.
|
|
95
95
|
*
|
|
96
|
-
* @
|
|
96
|
+
* @remarks
|
|
97
|
+
* If `false`, the pagination plugin does not apply its page-based `skip` or `limit`. Explicit query options
|
|
98
|
+
* and other query conditions still apply.
|
|
99
|
+
*
|
|
100
|
+
* @defaultValue `true`, unless overridden by plugin-wide defaults.
|
|
97
101
|
*/
|
|
98
102
|
pagination?: boolean;
|
|
99
103
|
populate?: PopulateOptions | PopulateOptions[] | string | string[];
|
package/dist/constants.d.ts
DELETED
package/dist/constants.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":";;qBAEa,qBAAqB"}
|
package/dist/constants.js
DELETED
package/dist/constants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { MongooseConnections } from './types';\n\nexport const mongooseConnections: MongooseConnections = {};\n"],"mappings":";AAEA,MAAa,sBAA2C,CAAC"}
|
package/dist/helpers.d.ts
DELETED
package/dist/helpers.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","names":[],"sources":["../src/helpers.ts"],"mappings":";;wBAEgB,oBAAoB,aAAa,MAAM"}
|
package/dist/helpers.js
DELETED
package/dist/helpers.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { Types } from 'mongoose';\n\nexport function toObjectIdHexString(id: string | Types.ObjectId) {\n return id instanceof Types.ObjectId ? id.toHexString() : id;\n}\n"],"mappings":";;AAEA,SAAgB,oBAAoB,IAA6B;CAC7D,OAAO,cAAc,MAAM,WAAW,GAAG,YAAY,IAAI;AAC7D"}
|
package/src/constants.ts
DELETED