Skip to content

Commit

Permalink
feat(): add bigint to built-in types
Browse files Browse the repository at this point in the history
  • Loading branch information
esahin90 committed Mar 11, 2024
1 parent b206d1d commit 0b2a908
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 0b2a908

Please sign in to comment.