WatermelonDB
WatermelonDB copied to clipboard
Compatibility with expo SQLite database
It was previously mentioned in #591 that it should be fairly easy to use the expo built-in SQLite driver with Watermelon.
We want to use watermelon with expo and are willing to write this adapter. However, I have no knowledge of the internals of this package at all.
As said in #591, it should be fairly easy. Can someone point to in the right direction on how to we could build this adapter?
Docs for expo SQLite: https://docs.expo.io/versions/v39.0.0/sdk/sqlite/
Much appreciated!
https://github.com/Nozbe/WatermelonDB/tree/master/src/adapters this dir contains all adapters
this type definition contains much of the API contract between an adapter and rest of the framework: https://github.com/Nozbe/WatermelonDB/blob/master/src/adapters/type.js
these tests are adapted for all adapters to validate their correctness with Watermelon: https://github.com/Nozbe/WatermelonDB/blob/master/src/adapters/tests/commonTests.js
here's the built-in SQLite adapter: https://github.com/Nozbe/WatermelonDB/blob/master/src/adapters/sqlite/index.js which further gets implemented by native iOS, Android, C++ JSI adapters… and a Node adapter: https://github.com/Nozbe/WatermelonDB/tree/master/src/adapters/sqlite/makeDispatcher/node -- you could probably make a dispatcher that talks to Expo SQLite but otherwise uses all the built-in SQLite JS code
@georgeboot hey, any updates?
any updates here guys?
Hi guys, sorry, no not yet.
I have started looking at it, but all time so fas has been spent on trying to read up on the internals and figure out what does what. No code written yet.
I kindof hoped that it would be relatively easy ("just copy adapter x and point it to a different binary") but it's a bit more challenging.
@radex
can you elaborate more about the makeDispatcher ? I m willing to do the implementation of that but need more clarification if possible
An implementation has been release, but I haven't been able to kickstart it. https://www.npmjs.com/package/@morrowdigital/watermelondb-expo-plugin
Do anyone has try it ? Can you guide us ?
I tried it, kept getting an error when it tries to write the "empty swift file wmelon.swift" from the Watermelon Docs. The filepath constructed within the plugin (or maybe its that it doesn't have permission to write?) is incorrect and it errors out. I modified that plugin trying to debug, but my inexperience in "everything" got in the way.
That said, android compiled just fine via plugin, and seemed to work with some of the other plugins I've wrote for other libraries (though they never had to create a new .swift file, just Podfile, InfoPList and Permissions edits/additions).
**Edit: I should add that I am only building in the cloud via eas build --platform ios --profile dev-client
I'm also working on an app with Expo and was planning on using WatermelonDB. An expo-sqlite adapter would be really useful to allow me to use the Expo Go app for testing.
I've given it a shot myself but similar to @georgeboot and @jakst (in #591) I found it challenging to grasp the specific internals of the package.
@sidferreira I noticed that you successfully implemented a solution for Node.js. I know it's been a couple of years since your contribution but maybe you have some guidance or knowledge to share on how one should approach this.
@Darhagonable, my Node port was really simple, almost a copy-and-paste, and sadly, I have limited experience with Expo.