How to query mongodb

40 views
Skip to first unread message

afriyie...@gmail.com

unread,
Jan 17, 2020, 4:11:13 AM1/17/20
to golang-nuts
Hi I have in my collection this JSON

{
"allowedSnssaiList": [
{
"allowedSnssai": {
"sst": 1,
"sd": "1"
},
"allowedSnssai": {
"sst": 2,
"sd": "3"
     }
   }
   ]
 }
how can query using the key sst and sd to return a documents matching the two exact values? Example when i query using sst:1, sd :1 it should return the documents but sst:1 and sd:3 should not. The problem am having is that when i query using "find" using sst:1, sd:3 it still return this JSON.

br
Abraham

burak serdar

unread,
Jan 17, 2020, 10:59:52 AM1/17/20
to afriyie...@gmail.com, golang-nuts
This is a mongodb question, it is not related to Go language. I
suggest you read the mongodb query manuals. What you're looking for
can be found under $elemMatch query.

>
> br
> Abraham
>
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/32eb3edb-d9c0-4c17-a4d0-2df0014b47cc%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages