How to get the values from MongoDB for user inputs

Hi I am creating collection(table) in mongodb like this; DateBase name: Sample Collection name: Sales

Id : xxxxxxxxxxxxx India:1,23,456 Usa: 2,34,794 Asia:12,34,689

Now i want to get the values for user inputs dynamically

I am trying this code :slight_smile:

myclient = pymongo.MongoClient(“mongodb://localhost:27017/”)

mydb = myclient[“sample”]

mycol = mydb[“sales”]

loc = tracker.get_slot(‘location’) // Inside the location values is India is stored in loc

counterNumber = mycol.count()

gettingTotalSize = mycol.find({}, {"_id": 0, “loc”: 1})

for x in gettingTotalSize:

dispatcher.utter_message(str(x[“loc”]))

return []

Is India the name of the key in the document or a value?

This translates to mycol.find({}, {"_id": 0, “India”: 1}.

What do you want to fetch from Mongo?

India is Key and that value is some amount like 2,654,654

So each country is a key and value is the amount?

Also, are you getting any errors?

No errors.I want logic for that

The logic seems fine. I use something similar for my backend and it works.

Ok thank you for replaying. I am done my own logic and it’s working fine

Thank you dued