On Tue, Mar 26, 2019 at 4:05 AM <[email protected]> wrote:
>
> Hi,
>
> Am using mongodb as database. Am able to query the database from the command
> line using the command
>
> db.nfinstances.distinct("ipv4Addresses",{"nfType":"AMF", "amfInfo.amfSetId":
> "3fa85f64-5717-4562-b3fc-2c963f66af33"})
>
> and this give me ipaddress [x.x.x.x] output that i want.
>
> mongo command line Output:
>
>
> > db.nfinstances.distinct("ipv4Addresses",{"nfType":"AMF",
> > "amfInfo.amfSetId": "3fa85f64-5717-4562-b3fc-2c963f66af33"})
>
> [ "198.51.100.300" ]
>
> >
>
>
> However if i query using the golang query
>
> var SliceIP []NfInstance
>
> db.C(COLLECTION).Find("nfType": "AMF", "amfInfo.amfSetId":
> "3fa85f64-5717-4562-b3fc-2c963f66af33").Distinct("ipv4Addresses", &SliceIP)
You need to pass a bson.M query:
db.C(COLLECTION).Find(bson.M{"nfType":AMF","amfinfo.amfSetId":"fa85f64-5717-4562-b3fc-2c963f66af33"})
>
> am getting empy array instead of the the IP address in an array. In the
> database i have the json document as
>
> {
> "nfinstanceID": "3fa85f64-5717-4562-b3fc-2c963f66af33",
> "nfType": [
> "AMF"
> ],
> "nfStatus": [
> "REGISTERED"
> ],
> "sNssais": [
> {
> "sst": 1,
> "sd": "sd1"
> }
> ],
> "nsiList": [
> "string"
> ],
> "ipv4Addresses": [
> "198.51.100.300"
> ],
> "allowedNssais": [
> {
> "sst": 1,
> "sd": "sd1"
> }
> ],
> "amfInfo": {
> "amfSetId": "3fa85f64-5717-4562-b3fc-2c963f66af33",
> "taiList": [
> {
> "plmnId": {
> "mcc": "244",
> "mnc": "38"
> },
> "tac": "string"
> }
> ],
> "n2InterfaceAmfInfo": {
> "ipv4EndpointAddress": [
> "198.51.100.105"
> ]
> }
> }
> }
>
> Can anyone help me find the problem. I may be doing missing something.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.