[SR-Users] ndb_mongodb -Sending Query to Mongo

Jonathan Hunter hunterj91 at hotmail.com
Wed Sep 21 14:36:55 CEST 2016

Hi Guys,
I am using the ndb_mongodb module, and Im just trying to return values from the dispatcher table, in particular the setid of a particular entry depending on its attrs value.
If I query using mongodb shell command it works fine, here I enter test.com and it returns only the setid value, or 2;
db.dispatcher.find( { attrs: "test.com" }, { setid: 1, _id: 0 } ){ "setid" : 2 }

However I have been having issues getting this to work using mongodb_find_one, as I would of thought the following route return the same;
if(mongodb_find_one("ml-mongodb", "kamailiosbc", "dispatcher", "{ \"attrs\" : \"test.com\" },{ \"setid\": \"1\", \"_id\": \"0\" }", "mgr1"))
However it returns all the entries relating to that attrs columm from dispatcher table, instead of just setid.
Is it possible to do this? I  am stuggling to find the json format to acheive the same thing.
Also in terms of the mgr1 response, I see its contained within the  $mongodb(key), can I drill down to get specific fields from it or would I need to use transformations or jansson to do this?
Many thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20160921/ccbd7097/attachment.html>

More information about the sr-users mailing list