react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

[📚] Documentation Issue - FilterFunction

Open val089 opened this issue 2 years ago • 40 comments

Documentation Feedback

Where can I find Filter instance to do multiple filter? I cant import it from anywhere.

https://rnfirebase.io/firestore/usage

I want to create something like this:

const snapshot = await firestore() .collection('Users') .where(Filter.and(Filter('user', '==', 'Tim'), Filter('email', '==', '[email protected]'))) .get();

val089 avatar May 24 '23 07:05 val089

#7124

pafry7 avatar May 30 '23 12:05 pafry7

@pafry7 Is this problem still in progress?

illlama avatar Jun 02 '23 14:06 illlama

i hope that they will fix this

coycoylaniba avatar Jun 04 '23 07:06 coycoylaniba

I'm waiting too.

val089 avatar Jun 04 '23 17:06 val089

@pafry7 Is this problem still in progress?

We are waiting for the reviewer

pafry7 avatar Jun 05 '23 06:06 pafry7

Really sorry for the delay!

Thank you so much @falleco for proposing PR #7124 to fix it and @pafry7 for the review!

It looks good to me and I am inclined to merge it but I will wait for a couple hours in the hope someone else here has a moment to glance over the final changes made in the last few hours to make sure they all look good?

mikehardy avatar Jun 05 '23 15:06 mikehardy

@mikehardy I've patched my project with the changes from PR and no problems so far.

pafry7 avatar Jun 05 '23 15:06 pafry7

Excellent - thanks again @pafry7 for the quality help - will merge that PR then, I'm queueing it with a batch of PRs that will all release today. Cheers!

mikehardy avatar Jun 05 '23 16:06 mikehardy

Anybody else still having problems? When I import Filter and try to use 'and' or 'or' functions, I get "TypeError: undefined is not a function" errors

emilstepanian avatar Jul 03 '23 11:07 emilstepanian

Where do you import Filter from? has anyone got a simple example? Thanks

markbarton avatar Jul 12 '23 13:07 markbarton

Where do you import Filter from? has anyone got a simple example? Thanks

I import from @react-native-firebase/firestore, but yeah, I still can't really use it

emilstepanian avatar Jul 17 '23 14:07 emilstepanian

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Aug 14 '23 15:08 github-actions[bot]

I'm still getting struggle after updated from 17.5.0 to 18.3.0 using like this

import firestore, { Filter } from '@react-native-firebase/firestore';

...

.collection(fbPinnedList)
    .where(Filter('location.longitude', '<=', longitude + searchSize))

or

.collection(fbPinnedList)
    .where(
      Filter.and(
        Filter('location.longitude', '<=', longitude + searchSize),
        Filter('location.longitude', '>=', longitude - searchSize)
      )
    )

And I think problem is Filter is detected as undefined. Because I can get bellow logs

TypeError: undefined is not a function
or
TypeError: Cannot read property 'and' of undefined

Can I get any hint?

illlama avatar Aug 16 '23 09:08 illlama

I'm also getting the same problem. I've upgraded the version to 18.3.0, and the Filter is now exported, but it's undefined. Another thing that I also have noticed, is that the types don't look right, I'm getting Filter: any

danielkv avatar Aug 21 '23 14:08 danielkv

trying to use Filter.or and getting a similar error TypeError: Cannot read property 'or' of undefined 🫤

jnwright avatar Aug 21 '23 18:08 jnwright

I've got to solve the problem. I created a patch to fix the issue.

It's happening because the Filter is not exported. I just exported the Filter from the index.js. I'll try to open a PR to fix it. Not sure if I can do it today though.

danielkv avatar Aug 21 '23 18:08 danielkv

Having the same problem here, Filter does not work and shows an error.

matmac avatar Sep 11 '23 08:09 matmac

Having the same problem here, Filter does not work and shows an error.

I'm trying to use filter.or and I get the same error. Did you find a solution?

gorkemunluyurt avatar Sep 12 '23 20:09 gorkemunluyurt

@danielkv sir, i tried exporting the filter from the index.js file but that also did not work. Can you please help with a patch log.

mahesh-agrawal-313 avatar Sep 15 '23 15:09 mahesh-agrawal-313

If anyone is still struggling with this, the following example might help. It worked for me

import firestore from "@react-native-firebase/firestore";

    const snapshot = await firestore()
      .collection<Connection>("connections")
      .where(
        firestore.Filter.or(
          firestore.Filter("sender", "==", user.email),
          firestore.Filter("receiver", "==", user.email)
        )
      )
      .get();

shrads12 avatar Sep 16 '23 23:09 shrads12

@shrads12 haven't worked for me.

@danielkv sir, i tried exporting the filter from the index.js file but that also did not work. Can you please help with a patch log.

@mahesh-agrawal-313 I'm sorry for the delay. This is the patch that I've created (I'm using yarn v3+):

@react-native-firebase-firestore-npm-18.3.0-0a6be6db66.patch

diff --git a/lib/index.d.ts b/lib/index.d.ts
index 74872beb39b215c95b3ae89691d19c60a7991491..536be01e02452f1a39947ed9838cd1d30698d91e 100644
--- a/lib/index.d.ts
+++ b/lib/index.d.ts
@@ -2340,7 +2340,7 @@ export const firebase: ReactNativeFirebase.Module & {
   ): ReactNativeFirebase.FirebaseApp & { firestore(): FirebaseFirestoreTypes.Module };
 };
 
-export const Filter: FilterFunction;
+export const Filter: FirebaseFirestoreTypes.FilterFunction;
 
 export default defaultExport;
 
diff --git a/lib/index.js b/lib/index.js
index 7b7e8167ff80bf77fdc879992038208f85c9de8e..e784737d688a121ce6f3ca3713d90a38f9d4c355 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -376,3 +376,5 @@ export default createModuleNamespace({
 // firestore().X(...);
 // firebase.firestore().X(...);
 export const firebase = getFirebaseRoot();
+
+export { Filter } from './FirestoreFilter'

danielkv avatar Sep 26 '23 12:09 danielkv

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Oct 24 '23 13:10 github-actions[bot]

Still relevant

haeniya avatar Oct 24 '23 14:10 haeniya

still an issue, but doing firestore.Filter works

artem-alek avatar Nov 13 '23 15:11 artem-alek

If someone posts a PR we can merge it + release 🙏

mikehardy avatar Nov 13 '23 18:11 mikehardy

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Dec 11 '23 18:12 github-actions[bot]

Still an issue

haeniya avatar Dec 11 '23 19:12 haeniya

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Jan 08 '24 20:01 github-actions[bot]

Still relevant

haeniya avatar Jan 08 '24 20:01 haeniya

If someone posts a PR we can merge it + release 🙏

mikehardy avatar Jan 30 '24 16:01 mikehardy