You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
how should BSON be configured or evaluated in order to process the longs compatibly but correctly?
The text was updated successfully, but these errors were encountered:
kuehn-sba
changed the title
I get 'new Long(“1668433278240”)' instead of 'Long {_bsontype: 'Long', low_: 1985962292, high_: 388 }'since using mongoose 6.x
I get 'new Long(“1985962292388”)' instead of 'Long {_bsontype: 'Long', low_: 1985962292, high_: 388 }'since using mongoose 6.x
Feb 12, 2025
kuehn-sba
changed the title
I get 'new Long(“1985962292388”)' instead of 'Long {_bsontype: 'Long', low_: 1985962292, high_: 388 }'since using mongoose 6.x
I get different format for long values back since using mongoose 6.x
Feb 13, 2025
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:
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 ofLong {_bsontype: 'Long', low_: 1985962292, high_: 388 }
since using mongoose 6.xand 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:
mongoose 6.x:
how should BSON be configured or evaluated in order to process the longs compatibly but correctly?
The text was updated successfully, but these errors were encountered: