Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(types): add BigInt support #13114

Closed
wants to merge 6 commits into from

Conversation

lpizzinidev
Copy link
Contributor

Summary
Added support for BigInt.
Support for the data type has been introduced in MongoDB driver 5.1.

Closes #13081

@Uzlopak Uzlopak changed the title feat(types): added BitInt support feat(types): added BigInt support Mar 2, 2023
@Uzlopak Uzlopak changed the title feat(types): added BigInt support feat(types): add BigInt support Mar 2, 2023
@lpizzinidev lpizzinidev changed the title feat(types): add BigInt support feat(types): added BigInt support Mar 2, 2023
@lpizzinidev lpizzinidev changed the title feat(types): added BigInt support feat(types): add BigInt support Mar 2, 2023
Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree with the high level direction of this PR. Specifically the decision to create a separate mongoose.Types.BigInt class.

The crux of BigInt support in mongodb@5.1 is support for JavaScript's native BigInt primitive. So Mongoose's treatment of BigInts should be analogous to Mongoose's treatment of numbers, not ObjectIds.

  1. castBigInt() should check for typeof value === 'bigint', and, if so, return value. Otherwise it should attempt to convert using BigInt(): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt
  2. We should add schema-level, collection-level, and global 'useBigInt64' options

@lpizzinidev
Copy link
Contributor Author

Closing this since headed in the wrong direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[7.x] Add native BigInt Support using latest driver
2 participants