mongodbprojectionrestheart

How to get only the value from int64 type with MongoDB


I use RestHeart to get data from MongoDB. When I request a document from a collection that contains a field of type int64 (in this example "INT64_NUMBER") the response contains:

"FLAG_A": "Y",
"FLAG_B": "N",
"INT64_NUMBER" {
    "$numberLong": "34"
},
"NUM_D": 123

Is there any option to obtain the same information without the type "$numberLong"? I mean, something like the following:

"FLAG_A": "Y",
"FLAG_B": "N",
"INT64_NUMBER": "34",
"NUM_D": 123

I thought that I should use some kind of aggregation with a project but I can't find a solution by myself neither an example on the web. Does anybody can guide me to find a proper solution? Thanks in advance.


Solution

  • No, you can't. That's the strict json representation of bson https://docs.mongodb.com/manual/reference/mongodb-extended-json/