My Atlas function performs a search & aggregates data. The function is working fine. I have an issue with datatype removal from the projected data. My integer fields come with datatype and I have exhausted alll options to remove datatype from the result.
My Atlas Function
exports = async function(arg){
let collection = context.services
.get('mongodb-atlas')
.db('et')
.collection('flashes');
let pipeline = [
{
$search: {
index: "flash",
text: {
query: arg,
path: {
wildcard: "*"
},
fuzzy :{
}
}
},
},
{
$project: {
_id: { $toString: "$_id" },
studioId: { $toString: "$studioId" },
name: 1,
tags: 1,
length: 1,
breadth: 1,
}
}
];
return collection.aggregate(pipeline);
};
Sample result
{
"name": "Snoop Dog Portrait",
"tags": [
"portrait",
"celebrity",
"snoop dog",
"shading",
"face portrait"
],
"length": {
"$numberInt": "6"
},
"breadth": {
"$numberInt": "7"
},
"_id": "643f7674b638e716b1501ecd",
"studioId": "643f74b9b638e716b1501e97"
}
The result I want to achieve is a json document with length & breadth fields with numbers. Not the datatupes.
I may have overlooked something. If anybody could help me figure out. I, will be grateful.
Regards