-
Notifications
You must be signed in to change notification settings - Fork 16
I get different format for long values back since using mongoose 6.x #24
Description
Has anything changed in the setup of mongoose 6.x? The way long datatypes are delivered by mongodb is different from the previous version of mongoose and I'm not sure how to correctly handle and transport values as (long) number in JS/JSON.
I have upgraded from MongoDB 5.x to MongoDB 6.x and Mongoose@5 to Mongoose@6. With 4.x and 5.x our client/server system works as it should.
An excerpt of the use in a scheme:
var Mongoose = require('mongoose');
require('mongoose-long')(Mongoose);
var SchemaTypes = Mongoose.Schema.Types;
var MySchema = new Mongoose.Schema({
..
..
timecode: {
type: SchemaTypes.Long,
min: 0,
default: 0
},
..
});
and I retrieve the document using 'find':
MySchema.find(options).sort(sortBy).skip(from).limit(size).batchSize(1000000)
as a result, I get the field back as new Long(“1985962292388”) instead of Long {_bsontype: 'Long', low_: 1985962292, high_: 388 } since using mongoose 6.x
and if I output it as JSON.stringify, then the return value with mongoose 5.x is still a string and with mongoose 6.x an object in this format:
mongoose 5.x:
"timecode": "1733151474200",
mongoose 6.x:
"timecode": {
"low": -2015313384,
"high": 403,
"unsigned": false
},
how should BSON be configured or evaluated in order to process the longs compatibly but correctly?