Bunny99
(Rapolu Durga prasad)
1
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
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?
Bunny99
(Rapolu Durga prasad)
3
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?
Bunny99
(Rapolu Durga prasad)
5
No errors.I want logic for that
The logic seems fine. I use something similar for my backend and it works.
Bunny99
(Rapolu Durga prasad)
7
Ok thank you for replaying. I am done my own logic and it’s working fine
Thank you dued