There is a way to clear persistence cache?

Hi. I’m having a problem when persistence is enabled.

I’ve sent some data to the firebase, which I can see on the console.
This data has an userID reference of the firebase user authenticated via facebook.
I have a several data there, but I can only get old data.

When I try to get this data through

firebaseApp.database().ref('my_path')
.orderByChild ('user')
.equalTo('user_id')
.once('value').then((snapshot) => console.log(snapshot.val()));

which was recently created always the response is null.

I did a test changing the user_id in user property in old data for the user_id used above and also I have get null.
And when I tried to get the user_id I was before, it came, even though it was changed to another user_id.

I was using version 1.1.2 and upgrade to version 2.0.0 but the problem persists.
What can I do to be able to access recently uploaded data?

Author: Fantashit

1 thought on “There is a way to clear persistence cache?

  1. @DavideValdo You need to set keepSynced before your requests:

    import firebase from 'react-native-firebase';
    import firebaseConfig from '../../config/firebase';
    
    const firebaseApp = firebase.initializeApp(firebaseConfig);
    const productsRef = firebaseApp.database().ref('products');
    
    productsRef.keepSynced(true);

    Then you use reference

    const response = await productsRef.orderByChild('merchant_id').equalTo(_vendorID).once('value');
    const products = response.val();

Comments are closed.

There is a way to clear persistence cache?

Hi. I’m having a problem when persistence is enabled.

I’ve sent some data to the firebase, which I can see on the console.
This data has an userID reference of the firebase user authenticated via facebook.
I have a several data there, but I can only get old data.

When I try to get this data through

firebaseApp.database().ref('my_path')
.orderByChild ('user')
.equalTo('user_id')
.once('value').then((snapshot) => console.log(snapshot.val()));

which was recently created always the response is null.

I did a test changing the user_id in user property in old data for the user_id used above and also I have get null.
And when I tried to get the user_id I was before, it came, even though it was changed to another user_id.

I was using version 1.1.2 and upgrade to version 2.0.0 but the problem persists.
What can I do to be able to access recently uploaded data?

Author: Fantashit

3 thoughts on “There is a way to clear persistence cache?

  1. @DavideValdo You need to set keepSynced before your requests:

    import firebase from 'react-native-firebase';
    import firebaseConfig from '../../config/firebase';
    
    const firebaseApp = firebase.initializeApp(firebaseConfig);
    const productsRef = firebaseApp.database().ref('products');
    
    productsRef.keepSynced(true);

    Then you use reference

    const response = await productsRef.orderByChild('merchant_id').equalTo(_vendorID).once('value');
    const products = response.val();

Comments are closed.