{"action":"created","issue":{"url":"https://api.github.com/repos/invertase/react-native-firebase/issues/196","repository_url":"https://api.github.com/repos/invertase/react-native-firebase","labels_url":"https://api.github.com/repos/invertase/react-native-firebase/issues/196/labels{/name}","comments_url":"https://api.github.com/repos/invertase/react-native-firebase/issues/196/comments","events_url":"https://api.github.com/repos/invertase/react-native-firebase/issues/196/events","html_url":"https://github.com/invertase/react-native-firebase/issues/196","id":237989322,"number":196,"title":"There is a way to clear persistence cache?","user":{"login":"lucianomlima","id":1580205,"avatar_url":"https://avatars1.githubusercontent.com/u/1580205?v=3","gravatar_id":"","url":"https://api.github.com/users/lucianomlima","html_url":"https://github.com/lucianomlima","followers_url":"https://api.github.com/users/lucianomlima/followers","following_url":"https://api.github.com/users/lucianomlima/following{/other_user}","gists_url":"https://api.github.com/users/lucianomlima/gists{/gist_id}","starred_url":"https://api.github.com/users/lucianomlima/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucianomlima/subscriptions","organizations_url":"https://api.github.com/users/lucianomlima/orgs","repos_url":"https://api.github.com/users/lucianomlima/repos","events_url":"https://api.github.com/users/lucianomlima/events{/privacy}","received_events_url":"https://api.github.com/users/lucianomlima/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-06-22T22:15:10Z","updated_at":"2017-07-04T15:42:25Z","closed_at":"2017-07-04T15:42:25Z","body":"Hi. I'm having a problem when persistence is enabled.\r\n\r\nI've sent some data to the firebase, which I can see on the console.\r\nThis data has an userID reference of the firebase user authenticated via facebook.\r\nI have a several data there, but I can only get old data.\r\n\r\nWhen I try to get this data through\r\n\r\n```javascript\r\nfirebaseApp.database().ref('my_path')\r\n.orderByChild ('user')\r\n.equalTo('user_id')\r\n.once('value').then((snapshot) => console.log(snapshot.val()));\r\n```\r\n\r\nwhich was recently created always the response is null.\r\n\r\nI 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.\r\nAnd when I tried to get the user_id I was before, it came, even though it was changed to another user_id.\r\n\r\nI was using version 1.1.2 and upgrade to version 2.0.0 but the problem persists.\r\nWhat can I do to be able to access recently uploaded data?"},"comment":{"url":"https://api.github.com/repos/invertase/react-native-firebase/issues/comments/312907595","html_url":"https://github.com/invertase/react-native-firebase/issues/196#issuecomment-312907595","issue_url":"https://api.github.com/repos/invertase/react-native-firebase/issues/196","id":312907595,"user":{"login":"Salakar","id":5347038,"avatar_url":"https://avatars3.githubusercontent.com/u/5347038?v=3","gravatar_id":"","url":"https://api.github.com/users/Salakar","html_url":"https://github.com/Salakar","followers_url":"https://api.github.com/users/Salakar/followers","following_url":"https://api.github.com/users/Salakar/following{/other_user}","gists_url":"https://api.github.com/users/Salakar/gists{/gist_id}","starred_url":"https://api.github.com/users/Salakar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Salakar/subscriptions","organizations_url":"https://api.github.com/users/Salakar/orgs","repos_url":"https://api.github.com/users/Salakar/repos","events_url":"https://api.github.com/users/Salakar/events{/privacy}","received_events_url":"https://api.github.com/users/Salakar/received_events","type":"User","site_admin":false},"created_at":"2017-07-04T15:42:25Z","updated_at":"2017-07-04T15:42:25Z","body":"This is intended firebase behaviour - the way `.on` works is it emits 2 events, firstly it emits whatever is locally persisted in the app and then the second time when it receives a response back from the server with fresh data. This helps keeps apps responsive during periods of poor or no network connectivity.\r\n\r\nNoting the above therefore `once` will always just give you the first one of those emitted events - the locally persisted state. As @akshetpandey suggested - you need to use `.on` - then when you have the fresh data (the second event) unsubscribe from the ref by subsequently calling `.off`."}}
{"actor":{"display_login":"Salakar"}}