realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.62k stars 558 forks source link

Web support / indexeddb implementation #517

Open eloff opened 7 years ago

eloff commented 7 years ago

I'm not sure if this is on the roadmap or not, but it would be nice to have a more uniform development experience between mobile and the web. I'd like to be able to use realm on all platforms - with realm for react native it should even be possible to share a lot of code between them.

Obviously the realm c++ database engine can't be used on the web, but as long as there's a compatible interface over indexeddb it would allow reuse of existing code and skills and make cross platform development easier. Performance won't be as good, but that's not the point. It will still be tolerable for many uses.

alazier commented 7 years ago

This is definitely something we have talked about and it would be nice to be able to support this at some point. Not sure when this will happen though.

geoffreywiseman commented 7 years ago

Yup -- mobile + web is a pretty common model, and while it wasn't THAT big a deal when Realm was basically just for local use, with the 'Realm Mobile Platform', having a website that can participate in realtime collaboration seems much more important.

509dave16 commented 7 years ago

@alazier Will an SDK for the Web be achieved through Web Assembly or IndexedDB? I'm not sure which would be preferable. My only reasoning would be that Web Assembly might allow you to use the same C++ core engine somehow, which is also used by all the other Realm client SDKs. Web Assembly is still in the works, but the Browser Vendors reached a consensus on Feb 28th. Edge and Safari have yet to support it, but I think by the end of the year all major browser vendors would have stable support. Just a guess.

McPo commented 6 years ago

Just throwing this out there but has anyone look into using emscripten?

I have used one other project, that uses it for its JS implementation (OLM https://git.matrix.org/git/olm). It looks like a great bit of kit, but I'm sure it has its limitations.

kristiandupont commented 6 years ago

@mcpo we have been looking at it as well as webassembly. It's an interesting idea but still not trivial as Realm relies on memory mapping which will not be available in the browser, so we would have to introduce a new abstraction layer.

motin commented 5 years ago

Any update on this? WebAssembly support is looking good these days: https://caniuse.com/#feat=wasm Having to use GraphQL for web and other SDKs for mobile / node is not ideal

Sybio commented 5 years ago

PWA is the new standard and it could be great to manipulate IndexedDB with strong wrapper like Realm !

bmunkholm commented 5 years ago

@Sybio The thing is that Realm is not just a "wrapper" :-) It a complete database with its own persistence.

GermanJablo commented 2 years ago

I find it interesting to mention this project here https://github.com/jlongster/absurd-sql

They have managed to make sqlite persistent on the web in a very clever (and absurd) way. Perhaps something similar can be done with realm.

alishefaee commented 4 weeks ago

I've used realm db on the Electron.js app using Node.js SDK. But I wished I could use web SDK locally. because I am using tauri.app with React.js for UI and realm db neither support Rust nor locally web SDK:

Unlike the other SDKs, the Web SDK only supports creating an in-memory database, not one persisted to disk.

I believe the main reason for not supporting local saving on disk is filesystem access limitation on browsers. Browsers nowadays offer file-system-access API that I think realm db can use this feature. Any thoughts on this?

kneth commented 3 weeks ago

Any thoughts on this?

We are looking at different options, and we hope to start the work later this year.