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

Use with expo-sqlite #15

Closed
smontlouis opened this issue Jun 23, 2022 · 8 comments
Closed

Use with expo-sqlite #15

smontlouis opened this issue Jun 23, 2022 · 8 comments

Comments

@smontlouis
Copy link

Awesome library! We've been waiting for this!

We're looking for a reactive react native library to communicate with sqlite.

Do you plan on making it compatible with expo-sqlite? May I ask what is your road map?

Thank you.

@quolpr
Copy link
Contributor

quolpr commented Jun 24, 2022

@smontlouis hey! I am glad that Trong meet your needs 🙂

I was able to connect expo (web and native) with Trong, here you can check example https://github.com/trong-orm/trong-expo-example.

You will need to specify custom webpack config:
https://github.com/trong-orm/trong-expo-example/blob/main/webpack.config.js

And create metro file:
https://github.com/trong-orm/trong-expo-example/blob/main/metro.config.js

@quolpr
Copy link
Contributor

quolpr commented Jun 24, 2022

As for the road map — add missing parts to query-builder, finish doc, add other platforms support

Fork absurd-sql, fix jlongster/absurd-sql#30 , maintain it.

Also, in the far future I want to build a data synchronization mechanism on top of the Trong

@quolpr
Copy link
Contributor

quolpr commented Jun 24, 2022

@smontlouis
Copy link
Author

smontlouis commented Jun 27, 2022

This is the best news of the week !

I've been delaying the native development of our project for a while now because I couldn't find a good offline-first strategy.
I took a look at watermelonDB, rxdb, realm, etc but for many reasons it was not what I was looking for.
I had some hope when I looked at riffle, but it seems to be still in its early stages.

And I'm very happy to see that you'll add a data sync on top of it, because it was something I was planning to manually handle ;)

@quolpr
Copy link
Contributor

quolpr commented Jun 29, 2022

I took a look at watermelonDB, rxdb, realm, etc but for many reasons it was not what I was looking for.

Yep, I too. I was developing https://github.com/quolpr/harika, and decided to move all ideas to Trong ORM 🙂 I tried watermelonDB, rxdb, realm too, and all of them were missing something. And, overall, IndexedDB just sucks in performance.

Regarding riffle— I am very excited too. There is a presentation that was uploaded recently where you can get some insides — https://www.youtube.com/watch?v=BmgL1SRfUyc

And I'm very happy to see that you'll add a data sync on top of it, because it was something I was planning to manually handle ;)

I am not sure when I will start working on it and how much time it will take. So I suggest for not is build your own sync system

@smontlouis
Copy link
Author

All good ! Thanks.

@quolpr may I ask what will be your strategy for the sync system ?
I've been reading a lot of interesting stuff lately, but I'm not sure what would be the best fit.

I took a look at jlongster's app and the database itself is CRDT-like.

I was thinking about having in addition of the regular sql tables a "messages" table that will contain all of the atomic changes happening in the db at a field level, like the crdt-example-app messages"table, with the timestamp and such.

As soon as an insert / update / delete action is performed with trong-orm, a message is sent to the server. If the user is offline, these messages are stored in the "messages" table.
The server would apply changes on the entities that have an updated_at lower than the timestamp of the messages.

It's quite a naive approach, but it's not a collaborative tool, just a multi-device tool with offline support.

Thank you !

@quolpr
Copy link
Contributor

quolpr commented Jul 4, 2022

@smontlouis good enough 🙂 Actually what I was doing — collecting all the changes on the client, sending to the server, server was recalculating all the changes from the start for a particular entity(and changes are ordered by timestamp + node name), and sending back the calculated entity. So there are no conflict should be happened, but some data could unexpectedly rewritten (in case when changes for the same field in the entity happened on two clients when both were offline) — for that case you can implement the time travel (because you have all the changes that were made before) 🙂

@quolpr
Copy link
Contributor

quolpr commented Jul 4, 2022

I want to implement similar algorithm that I described above on top of the trong-orm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants