Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

database sync (Offline Support) #1168

Open
natgross opened this issue May 20, 2021 · 44 comments
Open

database sync (Offline Support) #1168

natgross opened this issue May 20, 2021 · 44 comments
Assignees
Labels
backlog Issues waiting in the backlog discussion Gathering community feedback enhancement New feature or request
Projects

Comments

@natgross
Copy link

Does AW db support syncing devices? So devices can work offline, something like MongoDB Atlas, or [ahem] Firebase?

@eldadfux
Copy link
Member

We had initial thought on adding a separate library that will act as a proxy in front of Appwrite and sync any changes and provide offline cache depending on the user network status. The main idea was to handle it in separate layers to avoid added complexity to the API and avoid coupling.

@natgross
Copy link
Author

Since Appwrite is being billed as a Firebase replacement, I was hoping that it also includes database, which then means offline syncing like Firebase.

@eldadfux eldadfux changed the title database sync database sync (Offline Support) May 21, 2021
@eldadfux
Copy link
Member

I'll leave this issue open, and we'll update when we make progress in this front.

@eldadfux eldadfux added discussion Gathering community feedback enhancement New feature or request labels May 21, 2021
@1cedsoda
Copy link

1cedsoda commented Jul 2, 2021

I would love to see offline support for appwrite

Lately, I have been looking into offline document databases and offline support in firestore and noticed a few things

Firestore offline support works after an online-first paradigm.

  • Firestore allows you to specify a location to fetch from, either server or cache or automatic (default) if you are online every document is fetched from the database.
  • Out-of-the-Box firestore allows to create/edit/delete objects when the device is offline and this mechanism is very good and also well explained on YouTube.

I tried to implement a workaround for offline-first support for firestore with lastEdited timestamps, where it fetches "old" data from the cache and "new" data from the server. This works with a major flaw: The client won't detect if an object was deleted or query results changes that affects the cached documents.

An offline-first paradigm document database would be a firebase-killer for some people, like me in a current flutter project.
Users outdoor sometimes don't have an internet connection / mobile data flat at all, or a bad one.

I think of a client SDK with an offline-first/client sync document database that automatically

  • cache fetched data,
  • only pulls changed data
  • and query results that affects data in cache
  • There would also be a mechanism to tell the client which documents were deleted
  • There is a system to add/edit/delete locally and push changes later when the device is online
  • Run queries on the cache with indices

The only document database ,I know, that currently works on this functionality is MongoDB with its product "MongoDB Realm Sync". They aquired Realm some time ago who developed on-device databases. Sadly they haven't released an flutter SDK yet, because they are currently working with the dart developers to develop some new features for dart. Also as far as I remember MongoDB provides offline first support only in connection with their own priced hosting "MongoDB Atlas". There is no option to self-host a MongoDB with offline-first support.

@natgross
Copy link
Author

natgross commented Jul 4, 2021 via email

@de1mat
Copy link

de1mat commented Jul 9, 2021

It would be great if the offline data could be encrypted at rest as well.

@ccfiel
Copy link

ccfiel commented Sep 14, 2021

I think this is one major feature that lacking to compete with firebase or aws amplify to have offline first feature

@echosalik
Copy link

echosalik commented Oct 12, 2021

There are two competing Couchbase Lite Flutter implementations. They are both offline-first. Although incomplete api's, they function pretty much ok. https://pub.dev/packages?q=couchbase

I would suggest use something like SQLITE with JSON1 and Cipher APIs. It can act as a proxy, all data pull gets saved to sqlite too and any data pushed to server gets pushed to sqlite as well. That way even if network is not present or has poor performance, it can still work offline.

Now that proxy will be the determining factor to either load from sqlite or use live data.

@eldadfux eldadfux added the backlog Issues waiting in the backlog label Mar 19, 2022
@eldadfux eldadfux added this to To do in Backlog Mar 19, 2022
@jogehl
Copy link

jogehl commented Mar 21, 2022

This would really be a nice feature. Is there any plan to implement it?

@fivestones
Copy link

I agree that this would be a great feature. Is anything in the works to add it?

@meepeek
Copy link

meepeek commented May 22, 2022

WatermelonDB and RxDB seems to be the best starting point.

  • WatermelonDB is on client side. It comes with sync info and sync adapter for customize sync function to match any remote backend. It is also based on SQLite so appwrite team may share existing code since appwrite core is on mariadb. It also support RxJS API. See WatermelonDB
  • RxDB can sync with graphql server, this is an option if appwrite plans to support graphql. See RxDB

I would like to propose the idea as well as taking note for myself.

@bgervan
Copy link

bgervan commented May 22, 2022

WatermelonDB and RxDB seems to be the best starting point.

  • WatermelonDB is on client side. It comes with sync info and sync adapter for customize sync function to match any remote backend. It is also based on SQLite so appwrite team may share existing code since appwrite core is on mariadb. It also support RxJS API. See WatermelonDB
  • RxDB can sync with graphql server, this is an option if appwrite plans to support graphql. See RxDB

I would like to propose the idea as well as taking note for myself.

Both of it Js only or react only solutions. Appwrite provides SDK in other languages like flutter, which would be hard to implement that mechanism, and maintain different solution may not the best option. It's easier to come up with a self made solution which can be adapted to all client SDKs. If they implement CRDT on the client sides, then it's not that hard and it requires a few field only, like hibrid logical clock.

@meepeek
Copy link

meepeek commented Jun 19, 2022

@p4-k4 I too require that feature but I think it is a very complicate one. FOSS man power is limited so I think it could be a while before it ready. Currently, the most I can do for them is testing, propose ideas and report issues I came across as I use.

For now, I think the team has good progress that now I can use appwrite for my own user, data, api key management and also serverless approach to some extent.

Hopefully, this feature could come along with Apple's PWA support for push notification that might available next year. Once appwrite is solid enough, we'll all have the option to escape the big companies' jails.

@hey-nicolasklein
Copy link

Just checking in ahem 1 year later ;) Offline support is a dealbreaker for many cases, so much that it is the sole reason people look to Firebase (and as of recently, MongoDB Realm Flutter SDK beta was released with offline sync).

There's been another similar discussion for supbase but looks like discussion is being ignored regardless of the demand.

Currently seems Firebase and Realm are the only solutions to look to and the worst thing of it, they're all paid solutions and your data is held with someone else!

I would also add AWS Amplify as another similar solution with offline support. But like you've said, absolute vendor lock in.

@scriptsman
Copy link

Is there any other solution for web and flutter working fine with appwrite before official offline support come out?

@mmv-dev
Copy link

mmv-dev commented Aug 17, 2022

Did any tried WatermelonDB with appwrite. Or have any idea on how to connect. Please help me.
Thank your for your valuable time.

@nmdias
Copy link

nmdias commented Sep 4, 2022

This is a cherry on top feature. Giving a user instant access to a collection that is already locally cached, while it goes in the background to fetch for possible updates to that collection, is a killer feature.

Top of the head benefits:

  • Major user experience and usability upgrade for end users 🙋‍♂️
    • Offline usage
    • Handles unstable data connections, no blocking user flows
  • Developer joy 🥳
  • Instant access to cached documents 🚀
  • No unnecessary usage of cpu, memory, bandwidth for unchanged collections 🤤

I've read it was planned for after v1.0? Do we know if 1.0 is close, anyone?

@pchasco
Copy link

pchasco commented Sep 9, 2022

I don't consider this a "cherry on top" feature. It is a requirement for mobile apps whose network connectivity will always be unreliable.

@thirstycoda
Copy link

I don't consider this a "cherry on top" feature. It is a requirement for mobile apps whose network connectivity will always be unreliable.

I agree. Not having this feature is a deal breaker for me

@hey-nicolasklein
Copy link

I also think that Appwrite is not fully a self-hosted firebase without that feature. One of the main aspects of a firebase realtime database is the offline capabilities. As mobile devs we need this feature to fully replace firebase.

@mmv-dev
Copy link

mmv-dev commented Sep 14, 2022

Sincere request for the developers to implement this feature on priority. You will see a explosion in the count of users using Appwrite.

@iamshivkumar
Copy link

Waiting for this feature

@eldadfux eldadfux mentioned this issue Oct 18, 2022
2 tasks
@bazrafkan
Copy link

Any update for this feature?

@algoflows
Copy link

algoflows commented Jan 7, 2023

It's mental to me that no one is solving this issue with the only two players on the market being AWS and GCP. Every single metric shows increased mobile usage year over year, every one knows offline first is critical and necessary for serous multiplatform/mobile apps.

The only real viable options on the market right now for any product that includes mobile is Amplify, Firebase or Couchbase. You either need to roll your own offline online sync or switch back to one of the three listed above.

Developers expect and want clients that can sync with multiple backends. Mark my words the first company to bring a unified Graph data layer and offline sync wins the PAAS race. Developers want flexibility to move between different data solutions but also sync client server state with global consistency. Also the ability to access multiple data endpoints from a single graph client...

Imagine a world when choosing a globally distributed strongly consistent database for example CockroachDB were unified into a single Graph with any other db you wanted using something like (Hasura/Wundergraph) but then double that up with offline sync capabilities for offline first experiences.

Unstoppable.

@laurentpayot
Copy link

laurentpayot commented Jan 9, 2023

In a recent Meetup, a guy from a relatively big financial startup told me offline stuff is so complex that they were trying to reverse-engineer Firebase to see how they use IndexedDb in a reliable way.
Maybe appwrite offline support development effort was underestimated?

@TheRedSpy15
Copy link

TheRedSpy15 commented Jan 15, 2023

In a recent Meetup, a guy from a relatively big financial startup told me offline stuff is so complex that they were trying to reverse-engineer Firebase to see how they use IndexedDb in a reliable way. Maybe appwrite offline support development effort was underestimated?

Depends on the project and how it's structured. Firebase's offline implementation is really nothing more than a cache and compares timestamps when communicating with the server. Obviously I'm simplifying it, but that is the logic behind it

@pchasco
Copy link

pchasco commented Jan 15, 2023

In a recent Meetup, a guy from a relatively big financial startup told me offline stuff is so complex that they were trying to reverse-engineer Firebase to see how they use IndexedDb in a reliable way. Maybe appwrite offline support development effort was underestimated?

Depends on the project and how it's structured. Firebase's offline implementation is really nothing more than a cache and compares timestamps when communicating with the server. Obviously I'm simplifying it, but that is the logic behind it

It is quite complicated once you get into conflict resolution and things of that nature. Personally, I would have used CouchDB and Couchbase Sync Gateway for the backend. There is already Couchbase Lite (native) and PouchDB (JavaScript and IndexDB) for the client which enable offline-first with sync. The community editions are open source and free of charge, although I haven’t read the licenses to know whether there is some language that would prevent their usage in appwrite.

@eldadfux
Copy link
Member

eldadfux commented Mar 5, 2023

I can confirm this feature is in work. We’re planing to release a beta version of the Flutter SDK with full offline support. Once stable, we’ll replicate the design to the web SDK and then to both Android and iOS

@fivestones
Copy link

I can confirm this feature is in work.

This is awesome! It's the main thing I've been hoping for in appwrite all along...especially excited about that last one: iOS.

How are you going about this? Is it a form of CRDT? How are you dealing with conflict resolution? Just curious.

@laurentpayot
Copy link

@eldadfux Will offline persistence also work in web workers like Firestore?

@hortigado
Copy link

hortigado commented Mar 19, 2023

Great, it is important for me..

@mdajminpradhan
Copy link

I was almost sure that i'm gonna switch to appwrite. but suddenly searched whether appwrite has offline support or not. Now I see i have to wait for it.

Appwrite we need it ☺️♥️

@stnguyen90
Copy link
Contributor

For a sneak peek at our implementation of offline support, look at this discussion: #5326! We'd love to get your feedback!

@mghase
Copy link

mghase commented Jun 25, 2023

We had initial thought on adding a separate library that will act as a proxy in front of Appwrite and sync any changes and provide offline cache depending on the user network status. The main idea was to handle it in separate layers to avoid added complexity to the API and avoid coupling.

Where did this endup

@hortigado
Copy link

hortigado commented Jun 25, 2023

@mghase I recommend this package, I did some tests and I was able to implement it 100% with appwrite. Now I am deploying to a real project. It works very well and you can choose how you want the data to be sent and received from the server to be saved locally.
I'll try to make a tutorial when I finish the current project I'm working on
https://pub.dev/packages/brick_offline_first

@TechComet
Copy link

Hive Flutter
https://pub.dev/packages/hive_flutter
https://pub.dev/packages/hive

@ccfiel
Copy link

ccfiel commented Jul 20, 2023

I notice RFC is using a cache, not a local database? Can this handle lot of data? https://github.com/appwrite/rfc/tree/feat-offline-support/021-offline-support

@aliazimoshan
Copy link

This would really be a nice feature. Is there any update?

@rohankm
Copy link

rohankm commented Jul 26, 2023

I wrote a custom sync function for watermelondb and my app works offline in React native

@SMARTMICROWORLD
Copy link

SMARTMICROWORLD commented Nov 23, 2023

Is there any update @stnguyen90 ?

Also add offline feature for logged in users like we get logged in user data even after if device is offline like in firebase auth().currentuser. In react native

@Sun3
Copy link

Sun3 commented Feb 6, 2024

I am also looking for an update. Please give us at least an approximate date range and if this is even a priority. This is a crucial feature for any mobile app and without it, how can we switch from Firebase to AppWrite?

Thank you.

@hortigado
Copy link

@nathanael540
Copy link

Hello, does anyone have an example of how to use Appwrite with brick?

@xwchris
Copy link

xwchris commented Apr 29, 2024

I found this https://signaldb.js.org/examples/appwrite/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Issues waiting in the backlog discussion Gathering community feedback enhancement New feature or request
Projects
Backlog
  
To do
Development

No branches or pull requests