I have just started using MongoDB and RESTHeart api server.
I wish to replace my existing DB with MongoDB and existing DB too receives a json from the rest api, I thought the change would be little. So, below is the issue:
When I query MongoDB, this is what I get
{
"_collection-props-cached": false,
"_embedded": {
"rh:doc": [
{
"_etag": {
"$oid": "56ff559b7ea5c11edc8f93b7"
},
"_id": {
"$oid": "56ff559b7ea5c11edc8f93b6"
},
"_links": {
"self": {
"href": "/presence/active_watchers/56ff559b7ea5c11edc8f93b6"
}
},
"callid": "1-12285@10.0.1.168",
"contact": "sip:service@10.0.1.168:5060;transport=UDP",
"event": "presence",
},
{
"_etag": {
"$oid": "56ff55897ea5c11edc8f93b5"
},
"_id": {
"$oid": "56ff55897ea5c11edc8f93b4"
},
"_links": {
"self": {
"href": "/presence/active_watchers/56ff55897ea5c11edc8f93b4"
}
},
"callid": "1-12285@10.0.1.168",
"contact": "sip:service@10.0.1.168:5060;transport=UDP",
"event": "presence",
"event_id": "",
}
]
},
"_etag": {
"$oid": "56ff44807ea5c11edc8f93a6"
},
"_id": "active_watchers",
"_links": {
"curies": [],
"self": {
"href": "/presence/active_watchers"
}
},
"_returned": 2,
"descr": "subscriptions collection"
}
I am only interested in rh_doc array. My question is, is there a way I can just receive just the documents from the Monogo without the extra information.
The problem is, existing code expects just the array of values like [{callid:"123",...},{callid:"234",...}]
and it has been coded that way in C using cJSON. It feels scary to touch the C code!!
Or may be if CJSON can delete the keys: _etag, _id etc.
Edit This is how I query:
http GET "http://localhost:8080/presence/active_watchers?filter={'presentity_uri':'sip:service-1@opensipstest.org'}&filter={'event':'presence'}"
Thanks