#Possible to do an OR in withIndex

4 messages · Page 1 of 1 (latest)

slow grove
#

let's say I want to find all messages with isRead false or undefined, is that possible when doing withIndex?

slow robin
#

A withIndex query returns a contiguous range of documents, when the documents are sorted by the index field. So if you want to do an OR you can do two withIndex queries and merge the results.

In this very specific case, if the field can be only undefined, false, or true, you can use the ordering of undefined < false < true to query with q.lte("field", false) or q.lt("field", true) because that's a contiguous range

slow grove
#

how do you know that's the ordering?

#

or how would I determine what the sort order might be for various values?