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

Documentation about Native Access #12

Closed
Kausta opened this issue Sep 8, 2018 · 8 comments
Closed

Documentation about Native Access #12

Kausta opened this issue Sep 8, 2018 · 8 comments

Comments

@Kausta
Copy link

Kausta commented Sep 8, 2018

There is currently no documentation about native ( android, ios ) access to the db. Is it possible with the current api, or is it done manually via sqlite, or is there simply no documentation ?
Thanks

@radex
Copy link
Collaborator

radex commented Sep 8, 2018

What do you mean exactly? Do you want to access the database directly from native code, skipping JavaScript? What's your use case for this?

@Kausta
Copy link
Author

Kausta commented Sep 8, 2018

Sometimes we require shared objects stored between native code and javascript, and that is the reasons for wanting to access database directly from native code. I wondered whether this had direct support for such a thing.

@radex
Copy link
Collaborator

radex commented Sep 8, 2018

Currently no.

Do you need write access, or only read access? if read-only access, then it should be fairly easy to add support for native access (essentially just expose the DatabaseDriver object that DatabaseBridge - the native module - owns).

If you need to write to the database, then that would be in conflict with Watermelon, because if you add new items to the database from native code, Watermelon has no way of knowing that it might need to re-render some components.

@Kausta
Copy link
Author

Kausta commented Sep 11, 2018

Read access is okey, but write access, if there is a way to implement it, would be much better. It is possible to do it with Realm, one can read and write to the same .realm in Android, IOS and React Native. Having this with read/write ability on native would, in our eyes, make this a solid alternative to Realm. Is there currently a reason that there cannot be a way to have writes in native api ?

@radex
Copy link
Collaborator

radex commented Sep 11, 2018

Is there currently a reason that there cannot be a way to have writes in native api ?

Yeah, like I said:

If you need to write to the database, then that would be in conflict with Watermelon, because if you add new items to the database from native code, Watermelon has no way of knowing that it might need to re-render some components.

That makes it challenging to do, because Watermelon is asynchronous and multi-threaded. Not saying it's impossible — I've got some ideas. But that will take some time to implement.

@radex
Copy link
Collaborator

radex commented Nov 9, 2018

Closing this for now, as it's not anywhere near the top of the priorities list. If anyone wants to pick up the challange, I can give some guidance, but I warn you — it's not that simple as it seems ;)

@radex radex closed this as completed Nov 9, 2018
@Yarkhan
Copy link

Yarkhan commented Nov 21, 2019

Would you give directions about how to read the data from the native side?

My app consists of very long, frequently updating lists that I just can't get good performance out of it. My plan is to rewrite those screens in native Android / iOS, but keep all data writing in JS.

@radex
Copy link
Collaborator

radex commented Nov 25, 2019

use DatabaseBridge class, and methods on that.

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

3 participants