A simple $geoNear aggregation returns all my ObjectIds in the form of uInt8Arrays, and I cannot find out why:
let query = [
{$geoNear: {
near: geolocation,
spherical: true,
distanceField: "distance",
maxDistance: 50000,
distanceMultiplier : 0.000621371, //meters to miles
query: {
"field": true
}
}},
{$sort: {distance: -1}}
];
all IDs then look like this instead of the usual ObjectId("hexastring")
format
_id: Object
id: Uint8Array(12)
0: 204
1: 5
2: 102
3: 4
4: 0
5: 223
6: 92
7: 208
8: 42
9: 230
10: 236
11: 194
_bsontype: "ObjectID"
I am able to convert them to ObjectIds using
newObject._Id = new Mongo.ObjectID(newObject._id.toString());
but this is suboptimal and does not allow for querying for IDs in the actual query, as I do not know how to convert a normal ObjectId to the uInt8Array format (which caused this thread).
Any ideas?
Thanks in advance!