Skip to content

Commit

Permalink
Merge pull request #2080 from esahin90/feature/add-primitive-type-bigint
Browse files Browse the repository at this point in the history
feat(): add bigint to built-in types
  • Loading branch information
kamilmysliwiec committed Apr 5, 2024
2 parents 40fc3d1 + 0b2a908 commit 3268da5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/factories/definitions.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<unknown>): mongoose.SchemaDefinition {
Expand Down
5 changes: 5 additions & 0 deletions tests/e2e/schema-definitions.factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ class ExampleClass {

@Prop()
array: Array<any>;

@Prop()
bigint: bigint;
}

describe('DefinitionsFactory', () => {
Expand All @@ -103,6 +106,7 @@ describe('DefinitionsFactory', () => {
'customObject',
'any',
'array',
'bigint',
]);
expect(definition).toEqual({
objectId: {
Expand Down Expand Up @@ -130,6 +134,7 @@ describe('DefinitionsFactory', () => {
},
},
],
bigint: { type: BigInt },
buffer: { type: mongoose.Schema.Types.Buffer },
decimal: { type: mongoose.Schema.Types.Decimal128 },
child: {
Expand Down

0 comments on commit 3268da5

Please sign in to comment.