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
What are the plans of Mongoose to support BigInt? #6936
Comments
MongoDB does not support BigInt type atm. Creating a mongoose plugin for BigInt is possible though however you have to cast BigInt to string or binary in MongoDB. |
This is something we should be able to add for the future. JavaScript BigInts are just 64 bit ints, and MongoDB does support 64 bit ints, so we would just need to expand mongoose-long to cast BigInts. Should be doable. |
So which is right Vitaliy? Mongoose do not plan to support BigInt natively. Mongoose plans to support BigInt natively. Mongoose is indecisive at the moment. |
@koresar Sorry I didn't know that
|
Great to hear! BigInt is out since nodejs v10.3. |
I've taken a deeper look at the Run this line in latest Chrome console: const myBigInt = 2n**524288n;
console.log(myBigInt); It will render 157828 characters long string! So, @Fonger you were actually right in the beginning. I really doubt MongoDB would ever support this type of data. :) Let me clarify for future: mongoose does not support ESNext Thanks you all! |
Ah ok, I misread this part of the BigInt spec. This means we would need a new plugin, mongoose-long won't work. MongoDB does support storing binary data so we might store bigints using buffers. Thoughts? |
Sounds like a plan. The new plugin name better be |
This is really needed, Node.js now support BigInt natively and we definitely do not want to deal with Decimal128. |
The problem is that that MongoDB doesn't support BigInt at this moment. You can always use Binary (Buffer with mongoose) to store BigInt, however, anything related to arithmetic update operations won't work. Comparison in Binary has unexpected behavior too. and mongoose can't handle that for you. If what you want is just |
@Fonger that's an interesting idea, we should be able to store BigInts as buffers, but then you won't be able to do |
Starting node.js v10.3 the new data type was introduced - BigInt. It's Stage 3 atm.
Are there any plans or work going to support it same as
Number
,Buffer
,Date
,Map
etc are supported?The text was updated successfully, but these errors were encountered: