From 42a9afa064d3bd5bebbee5ab501f33782f19d665 Mon Sep 17 00:00:00 2001 From: Emre Sahin Date: Mon, 11 Mar 2024 09:27:33 +0100 Subject: [PATCH] feat: add bigint to built-in types See: https://mongoosejs.com/docs/schematypes.html#bigint --- lib/factories/definitions.factory.ts | 10 +++++++++- tests/e2e/schema-definitions.factory.spec.ts | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/factories/definitions.factory.ts b/lib/factories/definitions.factory.ts index 8d467df5..1e93df15 100644 --- a/lib/factories/definitions.factory.ts +++ b/lib/factories/definitions.factory.ts @@ -4,7 +4,15 @@ import * as mongoose from 'mongoose'; import { PropOptions } from '../decorators'; import { TypeMetadataStorage } from '../storages/type-metadata.storage'; -const BUILT_IN_TYPES: Function[] = [Boolean, Number, String, Map, Date, Buffer]; +const BUILT_IN_TYPES: Function[] = [ + Boolean, + Number, + String, + Map, + Date, + Buffer, + BigInt, +]; export class DefinitionsFactory { static createForClass(target: Type): mongoose.SchemaDefinition { diff --git a/tests/e2e/schema-definitions.factory.spec.ts b/tests/e2e/schema-definitions.factory.spec.ts index 347e6d37..d3348271 100644 --- a/tests/e2e/schema-definitions.factory.spec.ts +++ b/tests/e2e/schema-definitions.factory.spec.ts @@ -79,6 +79,9 @@ class ExampleClass { @Prop() array: Array; + + @Prop() + bigint: bigint; } describe('DefinitionsFactory', () => { @@ -103,6 +106,7 @@ describe('DefinitionsFactory', () => { 'customObject', 'any', 'array', + 'bigint', ]); expect(definition).toEqual({ objectId: { @@ -130,6 +134,7 @@ describe('DefinitionsFactory', () => { }, }, ], + bigint: { type: BigInt }, buffer: { type: mongoose.Schema.Types.Buffer }, decimal: { type: mongoose.Schema.Types.Decimal128 }, child: {