简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM