How to disable Firebase local DB writes?

684 views
Skip to first unread message

Ruben González Torres

unread,
Jan 11, 2017, 9:55:46 PM1/11/17
to Firebase Google Group
Hi:

I am building a collaboration app with Firebase Database. Because it is a complex collaboration app I need to save in the firebase only when the user is online (to avoid any collision between different users). I am not using offline capabilities but I am having a problem with the basic write/read functions when the device is offline. Because Firebase is saving the changes in a local DB first, even if the device is offline my app is showing the local data. And if the app is restarted then it shows the server data. I want to show only the server data.

Is it possible to don't save on the local DB and save directly on the server DB?
How can I detect if the update was saved correctly on the server?

Best
Ruben

Kato Richardson

unread,
Jan 12, 2017, 12:08:49 PM1/12/17
to Firebase Google Group
Hi Ruben,

What's the goal here? If you're worried about collisions, then you should probably either be using push() to ensure unique entries and work in more of an event stream, or utilize transactions if they will be writing to the same path.

Ideally, that would be a better solution than trying to manage connectivity--a complex process that Firebase does well without any oversight.

☼, Kato

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/eb964d24-8d0b-4373-84e7-7b1acedf273b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Ruben González Torres

unread,
Jan 12, 2017, 4:12:54 PM1/12/17
to Firebase Google Group
Hi Kato.

My app is used by other businesses to track time, job shifts, payroll. It is sensitive information that I want to allow changes only when the device in online and I can save it on the server right away. (Take a look at trello). I don't want to support offline access. Firebase is great for an app which is all in with offline capabilities. But I am trying to figure out how can I achieve what I need with firebase.

My main problem is even with offline capabilities off (Disk Persistence) every time that I write in the DB it is saving it locally before trying to save it online. And I don't know if it was synced with the server or it is only in the local DB.

My feeling is that firebase it is not going to work for what I want, but I want to be sure before I start migrating my infrastructure

Best
Ruben


On Thursday, January 12, 2017 at 9:08:49 AM UTC-8, Kato Richardson wrote:
Hi Ruben,

What's the goal here? If you're worried about collisions, then you should probably either be using push() to ensure unique entries and work in more of an event stream, or utilize transactions if they will be writing to the same path.

Ideally, that would be a better solution than trying to manage connectivity--a complex process that Firebase does well without any oversight.

☼, Kato
On Wed, Jan 11, 2017 at 6:15 PM, Ruben González Torres <rube...@gmail.com> wrote:
Hi:

I am building a collaboration app with Firebase Database. Because it is a complex collaboration app I need to save in the firebase only when the user is online (to avoid any collision between different users). I am not using offline capabilities but I am having a problem with the basic write/read functions when the device is offline. Because Firebase is saving the changes in a local DB first, even if the device is offline my app is showing the local data. And if the app is restarted then it shows the server data. I want to show only the server data.

Is it possible to don't save on the local DB and save directly on the server DB?
How can I detect if the update was saved correctly on the server?

Best
Ruben

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/eb964d24-8d0b-4373-84e7-7b1acedf273b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kato Richardson

unread,
Jan 12, 2017, 5:08:25 PM1/12/17
to Firebase Google Group
Ruben,

Transactions are still the best answer for concurrently edited data which needs to survive conflicts.

To determine if the data is saved in the database remotely, subscribe to the callbacks or promises; they resolve when the data is saved to the server. See receive a promise:

To know when your data is committed to the Firebase Realtime Database server, you can use a Promise. Both set()and update() can return a Promise you can use to know when the write is committed to the database.

☼, Kato


To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ruben González Torres

unread,
Jan 13, 2017, 7:15:53 PM1/13/17
to Firebase Google Group
Oh nice. Thanks Kato. I don't know how I missed that.
Reply all
Reply to author
Forward
0 new messages