How to create a permanent standalone database with electronic and pouchdb

I am going to write a desktop application that should keep its massive data persistent and local.

I want to write this application with electron . later I want to transfer the application to mobile. I am experimenting here with nativescript and angular-advanced-seed , which is trying to do code reuse on different platforms.

I want to use pouchdb as a database tool because I didn’t want the user to install / install an additional tool for having a database for a desktop application that runs separately.

In addition, I like to use pouchdb because it has this nice synchronization function with couchdb , which I can use later in the project when it becomes necessary to synchronize with the online database.

Now my questions

  • how can I use pouchdb to store data locally (this can be a mass of data that exceeds the localstorage limit), even when the application was stopped by the user. I need to load this data into the application the next time the user launches the desktop application. I read about pouchdb using leveldb, but I can't find the data to be saved.

  • Is it possible for an electron to have a database running inside an electronic application, so I don’t need to install mongodb on users ’PC / mobile application as well?

  • , (ios/android),

  • - () : A. , Desktop ()/Mobile (Android/IOS) Web B. - , (pouchdb/couchdb minimongo/mongodb). in-app api, - (minimongo/mongodb)

.

+4
2
+1

Pouchdb-Server. express-pouchdb.

'use strict'

console.log('Starting PouchDB...');

const express = require('express');
const PouchDB = require('pouchdb');
const app = express();

app.use('/', require('express-pouchdb')(PouchDB.defaults({prefix: '.db/'}), {
      overrideMode: {
        include: ['routes/fauxton']
      }
    })
);

app.listen(3000);

index.html.

<script type="text/javascript">require('./pouchdb-app.js');</script>

index.html pouchdb .

rxdb .

:

overrideMode: {
   include: ['routes/fauxton']
}

. . fauxton .


, RxDB example. Pouchdb-Server ( -) concurrently.

package.json:

  "scripts": {
    "start": "concurrently \"npm run server\" \"npm run electron\"",
    "electron": "electron .",
    "server": "pouchdb-server --host 0.0.0.0 -p 10102 -m -d /tmp/pouchdb-server/ -n true"

, PouchDB Angular , , .

0

Source: https://habr.com/ru/post/1660113/


All Articles