I want to remove properties _id and __v from Mongo result (which is array with markers) with map, but I always get array with null values in JSON result instead of array with objects without this two properties.
Marker.find().then(result => {
const markers = result.map(marker => {
delete marker['_id'];
delete marker['__v'];
});
res.send(JSON.stringify({ markers: markers }));
}).catch(next);
This is how returned JSON looks without mapping:
{
"markers": [
{
"_id": "5a7e266b6d7f6d00147bc269",
"id": "da27cbf8372aaeb24ce20a21",
"x": "25",
"y": "37",
"timestamp": 2093355239,
"__v": 0
},
{
"_id": "5a7e2789c61cf90014d67e6b",
"id": "5580d237f486088499c6d82k",
"x": "56",
"y": "29",
"timestamp": 2138203308,
"__v": 0
},
]
}
This is how returned JSON looks with mapping:
{
"markers": [
null,
null
]
}