Skip to content

Commit 0b2a908

Browse files
committed
feat(): add bigint to built-in types
See: https://mongoosejs.com/docs/schematypes.html#bigint
1 parent b206d1d commit 0b2a908

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/factories/definitions.factory.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@ import * as mongoose from 'mongoose';
44
import { PropOptions } from '../decorators';
55
import { TypeMetadataStorage } from '../storages/type-metadata.storage';
66

7-
const BUILT_IN_TYPES: Function[] = [Boolean, Number, String, Map, Date, Buffer];
7+
const BUILT_IN_TYPES: Function[] = [
8+
Boolean,
9+
Number,
10+
String,
11+
Map,
12+
Date,
13+
Buffer,
14+
BigInt,
15+
];
816

917
export class DefinitionsFactory {
1018
static createForClass(target: Type<unknown>): mongoose.SchemaDefinition {

tests/e2e/schema-definitions.factory.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ class ExampleClass {
7979

8080
@Prop()
8181
array: Array<any>;
82+
83+
@Prop()
84+
bigint: bigint;
8285
}
8386

8487
describe('DefinitionsFactory', () => {
@@ -103,6 +106,7 @@ describe('DefinitionsFactory', () => {
103106
'customObject',
104107
'any',
105108
'array',
109+
'bigint',
106110
]);
107111
expect(definition).toEqual({
108112
objectId: {
@@ -130,6 +134,7 @@ describe('DefinitionsFactory', () => {
130134
},
131135
},
132136
],
137+
bigint: { type: BigInt },
133138
buffer: { type: mongoose.Schema.Types.Buffer },
134139
decimal: { type: mongoose.Schema.Types.Decimal128 },
135140
child: {

0 commit comments

Comments
 (0)