Hi,
The problem wa about the index, i solved it by using the right index
bson.M{"amfInfo.taiList.tac": args[2]} since the fuction is called 

Da.FindIp(targetNfType, sst, sd, tac)

Thanks!

On Thursday, January 16, 2020 at 5:04:40 PM UTC+2, Afriyie Abraham Kwabena 
wrote:
>
> Hi,
>
> I have been trying to create a dynamic mongodb query using golang 
> interface but the logical $or does not work.
> It only return a documents when the input matches the 
> bson.M{"sNssais.sst": args[0].(int32), "sNssais.sd": args[1].(string)}.
> other matches like bson.M{"amfInfo.taiList.tac": args}, etc does not work 
> even though a document in mongodb collection exist that matches the input 
> value.
> Any idea as how to do this? The function is as below
>
> func (m *NfInstanceDataAccess) FindIp(preferredNfInstances string, args 
> ...interface{}) ([]model.NfProfile, bool) {
>     var ip []model.NfProfile
>     pipeline := bson.M{
>         "nfType": preferredNfInstances,
>         "$or": []interface{}{
>             bson.M{"sNssais.sst": args[0].(int32), "sNssais.sd": 
> args[1].(string)},
>             bson.M{"amfInfo.taiList.tac": args},
>             bson.M{"smfInfo.taiList.tac": args},
>             bson.M{"upfInfo.taiList.tac": args},
>         },
>     }
>     filter := bson.M{"ipv4Addresses": true}
>     err := db.C(COLLECTION).Find(pipeline).Select(filter).All(&ip)
>     if err != nil {
>         return ip, false
>     }
>     return ip, true
> }
>
>
>
>

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/1ee05646-077e-4e21-b9ee-3ac59cdd4e45%40googlegroups.com.

Reply via email to