Description
Issue
According to the document Filter.or
and Filter.and
should be able to accept themselves as arg:
const snapshot = await firestore()
.collection('Users')
.where(
firestore.Filter.or(
firestore.Filter.and(firestore.Filter('user', '==', 'Tim'), firestore.Filter('email', '==', '[email protected]')),
firestore.Filter.and(firestore.Filter('user', '==', 'Dave'), firestore.Filter('email', '==', '[email protected]')),
),
)
.get();
(Note that I've updated Filter
to firestore.Filter
due to this issue)
However this throws type error:
This is happening because type of Filter.or
and Filter.and
only accepts type of QueryFilterConstraint
while what they're returning is type of QueryCompositeFilterConstraint
:
react-native-firebase/packages/firestore/lib/index.d.ts
Lines 71 to 87 in ca07cad
So to address this issue, their type needs to be adjusted to accept either QueryFilterConstraint
or QueryCompositeFilterConstraint
:
export interface FilterFunction {
/**
* The Filter function used to generate an instance of Filter.
* e.g. Filter('name', '==', 'Ada')
*/
(fieldPath: keyof T | FieldPath, operator: WhereFilterOp, value: any): QueryFilterConstraint;
/**
* The Filter.or() static function used to generate a logical OR query using multiple Filter instances.
* e.g. Filter.or(Filter('name', '==', 'Ada'), Filter('name', '==', 'Bob'))
*/
or(...queries: (QueryFilterConstraint | QueryCompositeFilterConstraint)[]): QueryCompositeFilterConstraint;
/**
* The Filter.and() static function used to generate a logical AND query using multiple Filter instances.
* e.g. Filter.and(Filter('name', '==', 'Ada'), Filter('name', '==', 'Bob'))
*/
and(...queries: (QueryFilterConstraint | QueryCompositeFilterConstraint)[]): QueryCompositeFilterConstraint;
}
This works as I tested by updating the file in node_modules
.
But will the change introduce any other issues that I'm not aware of?
Project Files
Managed expo
Javascript
Click To Expand
package.json
:
"@react-native-firebase/analytics": "20.0.0",
"@react-native-firebase/app": "20.0.0",
"@react-native-firebase/app-check": "20.0.0",
"@react-native-firebase/auth": "20.0.0",
"@react-native-firebase/crashlytics": "20.0.0",
"@react-native-firebase/firestore": "20.0.0",
"@react-native-firebase/functions": "20.0.0",
firebase.json
for react-native-firebase v6:
# N/A
iOS
Click To Expand
ios/Podfile
:
- I'm not using Pods
- I'm using Pods and my Podfile looks like:
# N/A
AppDelegate.m
:
// N/A
Android
Click To Expand
Have you converted to AndroidX?
- my application is an AndroidX application?
- I am using
android/gradle.settings
jetifier=true
for Android compatibility? - I am using the NPM package
jetifier
for react-native compatibility?
android/build.gradle
:
// N/A
android/app/build.gradle
:
// N/A
android/settings.gradle
:
// N/A
MainApplication.java
:
// N/A
AndroidManifest.xml
:
<!-- N/A -->
Environment
Click To Expand
react-native info
output:
OUTPUT GOES HERE
- Platform that you're experiencing the issue on:
- iOS
- Android
- iOS but have not tested behavior on Android
- Android but have not tested behavior on iOS
- Both
react-native-firebase
version you're using that has this issue:20.0.0
Firebase
module(s) you're using that has the issue:Firestore
- Are you using
TypeScript
?Y
&5.3.3
- 👉 Check out
React Native Firebase
andInvertase
on Twitter for updates on the library.