A Stitch function returns value types for each non-string field. I believe this is because functions return data in MongoDB Extended JSON.
The Mongo Shell, on the other hand, returns standard JSON, and no value types.
How do I suppress value types returned by a MongoDB function? Is it possible to convert EJSON back to JSON?
For a date field, for example, the Mongo Shell returns:
"dob" : ISODate("1995-01-11T00:00:00.000-07:00")
The same query in a Stitch function returns:
"dob": {
"$date": {
"$numberLong": "232182000000"
}
My Stitch function looks like this:
exports = function(){
const collection = context.services.get("mongodb-atlas").db("mydb").collection("mycollection");
const doc = collection.find().toArray();
return doc;
};
Is there a helper function that can strip out the value types? Something like...
exports = function(){
const collection = context.services.get("mongodb-atlas").db("mydb").collection("mycollection");
const doc = collection.find().toArray();
const noValueTypes = doc.stripValueTypes()
return noValueTypes;
};