I need to get data of 'things': 'Animals', 'type': 'Mammals', 'dob' >= startDate and 'dbo' <= endDate
Is that possible to query like
ref.where('things', '==', 'Animals').where('type', '==', 'Mammals').where('dob', '>=', startDate).where('dob', '<=', endDate)
The range filter works with single ==
and not more than one ==
.
Is that possible to query like above? Or any other alternate way to achieve it?
The documentation here https://firebase.google.com/docs/firestore/query-data/queries
Says that to combine an equality with a range you need to create a composite index.
I imagine your query will work as you are only doing a range query on one field but you will need to create a composite index to do that.
You can read more about creating composite indexes here https://firebase.google.com/docs/firestore/query-data/indexing
As pointed out by AndrewHill in the comments. It looks like firestore will allow you to automatically create a composite index after the first time you try to query it. So this should definitely help out where needed. 👍🏻