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

[v3] Queries with equalTo() return null

Open murej opened this issue 7 years ago • 16 comments

Hey,

The following code returns null, however I do get a correct response using Firebase Web API.

firestack.database.ref('messages').orderByChild('uid').equalTo('wIRBRv9SdtfO7EUdhqL45tLhkzm2').on('value', (snapshot) => {
  console.log(snapshot.val());
});

Any ideas? Thanks for all the effort, much appreciation here

Edit: Using iOS

murej avatar Nov 09 '16 10:11 murej

I believe I'm getting this too.

Edit: I'm using android

pedro-ribeiro avatar Nov 09 '16 10:11 pedro-ribeiro

I believe I fixed it. Please review PR #122

pedro-ribeiro avatar Nov 09 '16 14:11 pedro-ribeiro

Wow awesome, thanks for working on it!

Tried it, and I do get this error: image

murej avatar Nov 09 '16 15:11 murej

I created the PR against the HEAD of master, but I didn't test it there. Maybe there's another issue. I'll have to investigate.

Edit: oh! and once again I've just tested it in android.

pedro-ribeiro avatar Nov 09 '16 15:11 pedro-ribeiro

Yeah, the : at the end is causing the problem, I think. We currently split on the :, so having that at the end would cause that error. I suppose we'll need to split on the first one and join the rest of the string together?

auser avatar Nov 09 '16 18:11 auser

Not completely sure I understood what you proposed since I'm not familiar with the ios code, but what about changing the equalTo code to conditionally pass the key variable?

equalTo(value, key) {
  // test key parameter here
  return this.query.setFilter('equalTo', value, key);
}

I guess that way it wouldn't have the trailing ':' due to having an undefined entry in the filters array.

pedro-ribeiro avatar Nov 09 '16 18:11 pedro-ribeiro

Well, it shouldn't actually have a trailing : in the key on iOS anyway... maybe it does in java, just not sure off-hand. Will have to check it...

auser avatar Nov 09 '16 18:11 auser

Anything I could help with here? Happy to get this forward. Thanks for the effort guys!

murej avatar Nov 14 '16 15:11 murej

Hey auser (& other contributors), this issue is fairly crucial for the project I'm working on with my team, so we're thinking of putting a bounty on it. We have the backing for it and would be happy to push the project this way. Any objections?

murej avatar Nov 16 '16 13:11 murej

@murej, can you give #137 a try?

pedro-ribeiro avatar Nov 16 '16 18:11 pedro-ribeiro

@auser, from what I've seen you have merged both #136 and #137. They do the same thing. imho, one of them should be reverted.

pedro-ribeiro avatar Nov 17 '16 13:11 pedro-ribeiro

This is working in v3 now. I think this can be closed @auser

moooji avatar Jan 12 '17 01:01 moooji

@moooji @auser I am still experiencing this bug and it looks like I'm not the only one. https://github.com/fullstackreact/react-native-firestack/issues/293 cc: @neuberoliveira

I'm considering migrating to @Salakar's https://github.com/invertase/react-native-firebase

Data filtering is crucial for my application.

Is this library still being maintained? There haven't been any updates in months.

AndrewHenderson avatar Mar 26 '17 22:03 AndrewHenderson

@AndrewHenderson can confirm this works and has also been tested over at my end, I fixed this in v3 firestack (my fork of firestack = v3) originally and works also in my repo as above.

Salakar avatar Mar 27 '17 11:03 Salakar

@Salakar I'm attempting to use your library. However, I'm having issues migrating to your project's API.

The docs on your repo seem to be out of date. npm i react-native-firebase installed v0.0.2. I went on to install v1.0.0-alpha9.

Since then, I've been troubleshooting signing in with Facebook. Currently, your Facebook sign in method fails silently.

// React Native Firestack
// This works.
firebaseApp.auth.signInWithProvider('facebook', data.accessToken, '');
// React Native Firebase
// This does not work.
firebaseApp.auth().signInWithCredential({
  provider: 'facebook',
  token: data.accessToken,
  secret: ''
});

I tried adding the Facebook app secret, but that didn't resolve the issue.

AndrewHenderson avatar Mar 27 '17 17:03 AndrewHenderson

@AndrewHenderson can you make an issue over at RNFirease please, but; I have taken a look though and can't see any issues with this, which platform isn't this working on? signInWithCredential returns a promise, to get any caught exceptions you'll need a .catch, can i see the full code for this if possible?

const credential = firebase.auth().FacebookAuthProvider.credential(data.accessToken);
// firebase.auth().FacebookAuthProvider will soon be moved to 
// firebase.auth.FacebookAuthProvider to match the firebase web sdk

firebase.auth().signInWithCredential(credential)
               .then(currentUser => {
                   // now signed in
                   console.warn(JSON.stringify(currentUser.toJSON()));
               })
               .catch(error => console.error(error));

Salakar avatar Mar 27 '17 17:03 Salakar