The Firebase team has just released a new update for the Javascript SDK, version 7.21.0 in which a new feature was just added which will save anyone who uses Firestore possibly a lot of money.
In the update, the feature introduces two new where
compatible query operators for filtering out data: not-in
and !=
.
not-in
finds documents where a specified field’s value is not in a specified array.!=
finds documents where a specified field’s value does not equal the specified value. Neither query operator will match documents where the specified field is not present.
Filtering in Firestore and Realtime Database has been notoriously limiting. You have to either query exactly what you want using where (say you want to get all items that have an active status). The ability to perform NOT IN
clauses inside of traditional databases has been a staple for years, but notably absent in Firebase.
As you can see in this StackOverflow question from 2014, it’s a feature that people have been wanting in Firebase for years. This is somewhat of a huge feature for Firestore users, one which can potentially save a lot of money and make your reads lighter.