I want to get data for ages over 30 using code
db.collection('persons').where(u"age", u">=", 30).get()
with a data structure like the following
but the database does not return any data, just an empty list
CodePudding user response:
The problem comes from the fact that your age
field is of type String (it’s shown between double quotes in the console), while your query is using a Number (the third parameter passed to the where()
method).
You don’t show how you create the doc but it’s there that you have to take care of writing this field with the desired type, i.e. Number in your case.
PS: there are probably two typos in your code with the where()
method: there are two extra u
.