最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Embedded database for electron, react-native and NodeJS apps? - Stack Overflow

programmeradmin5浏览0评论

I have a javascript application that I've implemented for mobile apps using react-native and its desktop counterpart using the electron framework. The mobile application uses react-native-sqlite-storage native module to save preferences and data (5 - 6 tables) whereas I use node-sqlite3 for the electron app.

Both, the mobile and desktop apps share a lot of functionality but due to the use of different database plugins, have a lot of differences. Also, for the desktop app, as node-sqlite3 is a native dependency, I have to build the app installers for Windows and macOS separately. That's a pain!

So, what I need is a database solution that is :-

  • embeddable into the app
  • efficient and performant pared to sqlite3
  • supports syncing to a remote database
  • supports macOS, Windows, and Linux
  • encrypts the data written within the database
  • consistent API across JS runtimes (Browser / NodeJS / JavascriptCore)

Here's a list of those that I've e across and that seem appealing:-

  • NeDB
  • RxDB
  • PouchDB

So, what are your suggestions and how have you implemented anything similar for your apps?

I have a javascript application that I've implemented for mobile apps using react-native and its desktop counterpart using the electron framework. The mobile application uses react-native-sqlite-storage native module to save preferences and data (5 - 6 tables) whereas I use node-sqlite3 for the electron app.

Both, the mobile and desktop apps share a lot of functionality but due to the use of different database plugins, have a lot of differences. Also, for the desktop app, as node-sqlite3 is a native dependency, I have to build the app installers for Windows and macOS separately. That's a pain!

So, what I need is a database solution that is :-

  • embeddable into the app
  • efficient and performant pared to sqlite3
  • supports syncing to a remote database
  • supports macOS, Windows, and Linux
  • encrypts the data written within the database
  • consistent API across JS runtimes (Browser / NodeJS / JavascriptCore)

Here's a list of those that I've e across and that seem appealing:-

  • NeDB
  • RxDB
  • PouchDB

So, what are your suggestions and how have you implemented anything similar for your apps?

Share Improve this question asked May 4, 2018 at 10:20 Ashishkumar PandeyAshishkumar Pandey 3061 gold badge4 silver badges14 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 15

I've been testing PouchDB, RxDB (which relies on PouchDB with RxJS streams for queries), Realm-JS (native database like sqlite3), FireStore. NeDB doesn't support remote sync.

I won't go into performance metrics details on each database, but PouchDB has been very slow and heavy on memory when querying more than 20.000 items (tried with indexeddb/websql adapter).

RxDB was generally much faster with that many items, especially when subscribing to query changes (tried with indexeddb/websql adapter too). Also schema and migrations are very handy.

FireStore is a good choice and es with very easy setup of server and client ponents, but you'll need to be fortable to run on a google platform. There is some flexibility with firebase functions if you want some control over server logic and there is customizable ACLs for your collections. Speed has been good and on par with RxDB. Comes with a very good auth module if you want it.

If you want to be able to scale much much more on the client side, which you probably don't, or if you want to make plex queries, I'd really remend using something like realm. You'll need to pile for each platform like you've experienced with sqlite3, but there is sync, offline persistence, rich queries and great performance. There is just no way that javascript based solutions like PouchDB, RxDB or FireStore can pete, even with sqlite backends, since much of the putation will still happen in your precious JS thread. realm is doing much of its heavy lifting on the native library. I've been able to do LIKE "abc" queries on 100.000 items, returning hundreds of results, within less than hundred milliseconds and without noticeably freezing my UI or pumping up memory usage heavily. Supports client migrations too, which is nice.

In the end, there are multiple answers: 1. Want to host everything yourself and don't need massive scale client side (you can sync against subsets of your server data with filters), RxDB ist very good and es with nice set of features. 2. Want very easy setup, nice modules like auth, server functions etc, and don't need massive scale on the client (can also sync against server data subsets with filters), FireStore is great. 3. Need lots of lots of data on the client, realm is my preference. I personally really dislike the realm sync platform for its pricing model (though technically it's cool), but the database itself is free and maybe you could try and implement a custom sync.

Take my results with a grain of salt, I've had some very specific challenges like large, non-relational collections and fulltext-search, your use-case will probably differ a lot.

发布评论

评论列表(0)

  1. 暂无评论