I am writing Mongodb Stitch, functions.
The weird part is, writing it within Mongodb Stitch function client, it has to do BSON.ObjectId
const games = mongodb.collection("games");
const gameId = "5cb9404ffc6da85909eb561c";
const objectId = BSON.ObjectId(gameId);
const query = { "_id" : objectId };
return games.findOne(query);
But, when I use my app to pass the arg
to the function, it will complain
[StitchServiceError: Error: ObjectId in must be a single string of 12 bytes or a string of 24 hex characters]
Which I have to revert it back to
const gameId = "5cb9404ffc6da85909eb561c";
const query = { "_id" : gameId };
return games.findOne(query);
Which this will return null
if I test it within MongoDB Stitch function client.
Why MongoDB designs in this way?