@kikiutils/mongoose 9.0.0 → 9.0.1
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/dist/types/data.d.ts +2 -1
- package/dist/types/data.d.ts.map +1 -1
- package/dist/types/index.d.ts +7 -3
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/types/data.ts +4 -1
- package/src/types/index.ts +16 -2
package/dist/types/data.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export type BaseMongooseModelData<CreatedAtField extends boolean = true, Updated
|
|
|
8
8
|
} : unknown) & {
|
|
9
9
|
id: string;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
/** Converts data fields to document fields using the same `_id` rules as BaseMongooseDocType. */
|
|
12
|
+
export type DataToBaseMongooseDocType<T, ObjectIdFields extends keyof T = never, DateFields extends Exclude<keyof T, ObjectIdFields> = never, CreatedAtField extends boolean = true, UpdatedAtField extends boolean = true, IdField extends boolean = true> = BaseMongooseDocType<SetFieldsToObjectId<SetFieldType<T, DateFields, Date>, ObjectIdFields>, CreatedAtField, UpdatedAtField, IdField>;
|
|
12
13
|
//#endregion
|
|
13
14
|
//# sourceMappingURL=data.d.ts.map
|
package/dist/types/data.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.d.ts","names":[],"sources":["../../src/types/data.ts"],"mappings":";;;YAOY,sBAAsB,uCAAuC,0CACpE;EAAgC;gBAChC;EAAgC;;EAC/B
|
|
1
|
+
{"version":3,"file":"data.d.ts","names":[],"sources":["../../src/types/data.ts"],"mappings":";;;YAOY,sBAAsB,uCAAuC,0CACpE;EAAgC;gBAChC;EAAgC;;EAC/B;;;YAGM,0BACR,GACA,6BAA6B,WAC7B,mBAAmB,cAAc,GAAG,yBACpC,uCACA,uCACA,kCACA,oBACA,oBAAoB,aAAa,GAAG,YAAY,OAAO,iBACvD,gBACA,gBACA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { AggregatePaginateModel } from "./aggregate-paginate.js";
|
|
2
2
|
import { PaginateModel } from "./paginate.js";
|
|
3
|
-
import { HydratedDocument, QueryWithHelpers, Types } from "mongoose";
|
|
3
|
+
import { HydratedDocument, QueryWithHelpers, Require_id, Types } from "mongoose";
|
|
4
4
|
import { SetFieldType } from "type-fest";
|
|
5
5
|
//#region src/types/index.d.ts
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Raw document type with an ObjectId by default, or the `_id` type declared in T.
|
|
8
|
+
* Set IdField to false for schemas with `_id: false`. Nested fields are left unchanged.
|
|
9
|
+
*/
|
|
10
|
+
export type BaseMongooseDocType<T, CreatedAtField extends boolean = true, UpdatedAtField extends boolean = true, IdField extends boolean = true> = (CreatedAtField extends true ? {
|
|
7
11
|
createdAt: Date;
|
|
8
|
-
} : unknown) & Omit<T, 'createdAt' | 'id' | 'updatedAt'> & (UpdatedAtField extends true ? {
|
|
12
|
+
} : unknown) & (IdField extends true ? Require_id<Omit<T, 'createdAt' | 'id' | 'updatedAt'>> : Omit<T, '_id' | 'createdAt' | 'id' | 'updatedAt'>) & (UpdatedAtField extends true ? {
|
|
9
13
|
updatedAt: Date;
|
|
10
14
|
} : unknown);
|
|
11
15
|
export type BaseMongoosePaginateModel<RawDocType, InstanceMethodsAndOverrides = object, QueryHelpers = object> = AggregatePaginateModel<RawDocType, QueryHelpers, InstanceMethodsAndOverrides> & BaseMongooseModelStatics<RawDocType, InstanceMethodsAndOverrides, QueryHelpers> & PaginateModel<RawDocType, QueryHelpers, InstanceMethodsAndOverrides>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/types/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/types/index.ts"],"mappings":";;;;;;;;;YAeY,oBACR,GACA,uCACA,uCACA,mCAEC;EAAgC,WAAW;gBAE5C,uBACM,WAAW,KAAK,wCAChB,KAAK,iDAEV;EAAgC,WAAW;;YAEpC,0BAA0B,YAAY,sCAAsC,yBACpF,uBAAuB,YAAY,cAAc,+BACjD,yBAAyB,YAAY,6BAA6B,gBAClE,cAAc,YAAY,cAAc;YAEhC,sCAAsC,GAAG,gBAAgB,KAAK,KAAK,+BAA+B;YAClG,2BAA2B,KAAK,aAAa,MAAM;YACnD,0BACR,YACA,SACA,uBACA,wCACA,iBACI,gBACA,SACA,cACA,uBAEA;YAGI,yBACR,SACA,sCACA,yBACA,iBACA,SACA,6BACA;YAGQ,oCAAoC,GAAG,8CAA8C,KAC7F,+BAC4B;YAGpB,oBAAoB,GAAG,gBAAgB,KAAK,aAAa,GAAG,GAAG,MAAM;iBAIhE,yBAAyB,YAAY,sCAAsC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kikiutils/mongoose",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "9.0.
|
|
4
|
+
"version": "9.0.1",
|
|
5
5
|
"description": "Provides Mongoose schema builders and utilities for connections, pagination, JSON normalization, and update checks.",
|
|
6
6
|
"author": "kiki-kanri",
|
|
7
7
|
"license": "MIT",
|
|
@@ -82,14 +82,14 @@
|
|
|
82
82
|
"dependencies": {
|
|
83
83
|
"decimal.js": "^10.6.0",
|
|
84
84
|
"es-toolkit": "^1.52.0",
|
|
85
|
-
"mongoose": "^9.
|
|
85
|
+
"mongoose": "^9.11.0",
|
|
86
86
|
"mongoose-aggregate-paginate-v2": "^1.1.5",
|
|
87
87
|
"mongoose-paginate-v2": "^1.9.5",
|
|
88
88
|
"type-fest": "^5.10.0"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@antfu/eslint-config": "^9.5.1",
|
|
92
|
-
"@kikiutils/eslint-config": "^9.
|
|
92
|
+
"@kikiutils/eslint-config": "^9.3.0",
|
|
93
93
|
"@kikiutils/tsconfigs": "^7.0.0",
|
|
94
94
|
"@types/node": "^26.6.4",
|
|
95
95
|
"@vitest/coverage-v8": "^5.0.3",
|
package/src/types/data.ts
CHANGED
|
@@ -10,14 +10,17 @@ export type BaseMongooseModelData<CreatedAtField extends boolean = true, Updated
|
|
|
10
10
|
& (UpdatedAtField extends true ? { updatedAt: string } : unknown)
|
|
11
11
|
& { id: string };
|
|
12
12
|
|
|
13
|
+
/** Converts data fields to document fields using the same `_id` rules as BaseMongooseDocType. */
|
|
13
14
|
export type DataToBaseMongooseDocType<
|
|
14
15
|
T,
|
|
15
16
|
ObjectIdFields extends keyof T = never,
|
|
16
17
|
DateFields extends Exclude<keyof T, ObjectIdFields> = never,
|
|
17
18
|
CreatedAtField extends boolean = true,
|
|
18
19
|
UpdatedAtField extends boolean = true,
|
|
20
|
+
IdField extends boolean = true,
|
|
19
21
|
> = BaseMongooseDocType<
|
|
20
22
|
SetFieldsToObjectId<SetFieldType<T, DateFields, Date>, ObjectIdFields>,
|
|
21
23
|
CreatedAtField,
|
|
22
|
-
UpdatedAtField
|
|
24
|
+
UpdatedAtField,
|
|
25
|
+
IdField
|
|
23
26
|
>;
|
package/src/types/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
HydratedDocument,
|
|
3
3
|
QueryWithHelpers,
|
|
4
|
+
Require_id,
|
|
4
5
|
Types,
|
|
5
6
|
} from 'mongoose';
|
|
6
7
|
import type { SetFieldType } from 'type-fest';
|
|
@@ -8,9 +9,22 @@ import type { SetFieldType } from 'type-fest';
|
|
|
8
9
|
import type { AggregatePaginateModel } from './aggregate-paginate';
|
|
9
10
|
import type { PaginateModel } from './paginate';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Raw document type with an ObjectId by default, or the `_id` type declared in T.
|
|
14
|
+
* Set IdField to false for schemas with `_id: false`. Nested fields are left unchanged.
|
|
15
|
+
*/
|
|
16
|
+
export type BaseMongooseDocType<
|
|
17
|
+
T,
|
|
18
|
+
CreatedAtField extends boolean = true,
|
|
19
|
+
UpdatedAtField extends boolean = true,
|
|
20
|
+
IdField extends boolean = true,
|
|
21
|
+
> =
|
|
12
22
|
& (CreatedAtField extends true ? { createdAt: Date } : unknown)
|
|
13
|
-
&
|
|
23
|
+
& (
|
|
24
|
+
IdField extends true
|
|
25
|
+
? Require_id<Omit<T, 'createdAt' | 'id' | 'updatedAt'>>
|
|
26
|
+
: Omit<T, '_id' | 'createdAt' | 'id' | 'updatedAt'>
|
|
27
|
+
)
|
|
14
28
|
& (UpdatedAtField extends true ? { updatedAt: Date } : unknown);
|
|
15
29
|
|
|
16
30
|
export type BaseMongoosePaginateModel<RawDocType, InstanceMethodsAndOverrides = object, QueryHelpers = object> =
|