Closed
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Mongoose version
6.4.5
Node.js version
16.20.1
MongoDB server version
7.0.0
Typescript version (if applicable)
5.2.2
Description
The value 14055648105137340n returns undefined if you save it in a BigInt
MongoDB Atlas shows it nicely as an Int64.
The signed type, Int64, can hold values from -9223372036854775808 to 9223372036854775807. The unsigned type, Uint64, can hold values from 0 to 18446744073709551615.
9223372036854775807 <- max range
14055648105137340n <- The value we tried to use doesn't work
1305564810513734n <- This value does work
I added a fix (#13787) with patch package to test if this helps but it didn't help
Steps to Reproduce
export interface IBlock {
n: number;
reward: BigInt;
}
export const Block = model<IBlock>(
'Block',
new Schema<IBlock>({
n: Number,
reward: BigInt
}),
);
let a = await Block.create({n: 1, reward: 14055648105137340n});
let b = await Block.findOne({n: 1});
console.log(14055648105137340n);
console.log('create : ', a);
console.log('findOne : ', b);
let c = await Block.create({n: 2, reward: 1305564810513734n});
let d = await Block.findOne({n: 2});
console.log(1305564810513734n);
console.log('create : ', c);
console.log('findOne : ', d);
Expected Behavior
We expected to get the BigInt up to 9223372036854775807n returned