Electron Desktop Application communicating with remote NoSql server - node.js

I've begun to dive into developing a desktop application with electron. I have been interested in pairing this application with a NoSQL database to create users, display data, and do CRUD operations. I've considered databases such as MongoDB and CouchDB, and I'm curious if creating a desktop application that communicates with a database hosted elsewhere is a feasible goal.
I'm hoping that someone here can help direct me to great resources on creating a desktop application that works with a remote NoSQL database. Any advice here would be greatly appreciated!

I recommend the use of CouchDB, which uses a JSON based document format. CouchDB bundles the server and data storage functionality in a single product, providing a REST-like HTTP interface for document insertion, updates, retrieval and deletion.
Therefore, you'll be able to interact with CouchDB directly from within the Electron desktop application. Apache CouchDB Nano is the official Node.js library for accessing CouchDB.
The following additional factors speach for CouchDB:
It is open source.
It has comprehensive documentation.
It is available for Linux, macOS and Windows.
It's easily installed and quickly set up.
It can be installed on your local computer (for development), on your own servers, or in the cloud.
It supports Mango querying language (inspired from MongoDB).
It is highly scalable.
It is shipped with Fauxton web interface that lets you create, update, delete, view and query documents on the fly.
etc.

Related

When should we use NodeJS and when should we use MongoDB?

As a new developer, I am always confused about using NodeJS and MongoDB. So I hope I will get an actual answer. Thanks...
MongoDB and NodeJS are two different technologies. MonogDB is a database system which gives you a chance to efficiently store documents in a database and to perform operations like data updates, or to search documents by some criterias.
NodeJS's responsibilty is especially to execute your application.
Nodejs is a Javascript engine that you can write any application you want with (by programming in the Javascript language). It runs your Javascript code. Most commonly, it is used to build servers that can respond to web requests, though it can be used for lots of other types of code too.
MongoDB is a database engine. Code within some application or server uses MongoDB to save, query or update data in a database. There are many web servers built with nodejs that will then use MongoDB for storing data.
MongoDB offers an API library that runs within a Nodejs application to give you programmatic access to MongoDB so you can create databases and then add, query, update or delete data from the MongoDB database. MongoDB also has API libraries for other programming environments such as Python, Java, etc...
These two technologies are for different parts of a typical web server system. You don't substitute one for the other. Instead, you can use them together.
When should we use Nodejs?
Any project needs a programming environment and a runtime library that offers you basic programming tools/support and can compile and/or interpret your code. Nodejs is such as tool for the Javascript programming language. There are other similar tools for other languages such as Python, Java, PHP, C#, C++, Go, etc...
So, if you want to write some kind of stand-alone program or server in Javascript, then you can use nodejs for it.
When should we use MongoDB?
If your application needs the ability to persistently store data in a way that you can efficiently query or update it later, then you would typically use some form of database. There are dozens of popular databases. MongoDB is one such database. MariaDB, MySql, CouchDB, DynamoDB (on AWS), Postgres are examples of other databases. Different databases have different strengths (things they are best at) and different ways of using them so it's a whole different question to choose the right/best database for what you're doing.
Here is a Blog link that will tell you when you should use NodeJS.
Here is another link to understand when you should use mongoDB.
Well, NodeJS and MongoDB are two different process. Here I tried to explain as simpler as possible:
NodeJS
Shortly we can say, NodeJS is a JavaScript runtime environment. It's actually helps JavaScript to run outside of server. It's used in server side development.
MongoDB
But, MongoDB is NoSQL database which is document oriented. It represents data as of JSON documents. It's used for store data.
Summary
The summary is MongoDB is a database where we can store data and NodeJS helps us to to connect our client site to database by it's server site.
Example:
Suppose you are building a website and you need a database to store the data or information so here you can use MongoDB but to be connected with MongoDB you need a connector, so here you can use NodeJS which will help your website to run outside of server.
Nodejs: Node.js is an interpreter or runtime/ running environment for JavaScript. built on Chrome's V8 JavaScript engine. responsibility is especially to execute your application.
MongoDB: is a No-SQL database for storing data. when you need high availability of data with automatic, fast, and instant data recovery.

PouchDB with CouchDB with Node Web Api Server Layer?

Just trying to spec out a new system. We want to build a mobile app with offline storage using react-native.
We were originally going to use node and create a web api layer that worked with a MongoDB. However after looking into offline storage we found PouchDB. But pouch has to use CouchDB. So we are considering using CouchDb and having a flat db layer with all our business and data logic modelled in the apps.
However there may be some server side things that we need to do (for example pulling other records from somewhere else in the organisation).
So can we deploy a web api using node alongside CouchDb? How would this work? Totally separate or in the same node process?
So can we deploy a web api using node alongside CouchDb?
Yes, of course.
How would this work?
I'm not sure about what solution suites your needs, but one solution is to develop a web app with this tech-stack: NodeJS/Express, CouchDB/PouchDB and ReactJS/MobX. One important point about CouchDB is that, you shouldn't think about it like any other database . Basically, you don't need any server-side code to talk to CouchDB, it can all be done on the client-side with PouchDB. The live sync of PouchDB is extremely convenient at handling offline/online storage. If you're considering ReactJS, take a look at MobX.

Management tool for PouchDB

I am planning to use PouchDB as embedded database for a Node.js application.
Is there any tools (possibly for Linux), to inspect the db, run queries, and modify documents? Something similar to Robomongo for MongoDB? Or similarly to one of the many management tool for SQLite databases?
I know that one solution might be to run a CouchDB server locally and activate the two-way synchronization between the two. But this quite cumbersome process.
I also found PouchDB Inspector for Chrome but it does not seems possible to load the database directory directly as one would do, for example, with an SQLite database.

NoSQL database: ArangoDB

I have been looking for a database that can be embedded and also be file-based, like Sqlite.
I wanted a NoSQL type of database with this kind of feature.
The language is Python, and ArangoDB has binding for Python, and many other languages.
I am finding conflicting facts about ArangoDB.
In some cases I have seen articles say it is not an embedded DB, or can't be embedded, then see others that imply it is embedded.
Also on the website it says that it stores its data in a special binary format, and then I see an article saying its mainly an In-Memory database.
So its been very confusing.
1)So the question is, can this database run embedded in a python app?
If not, if it runs as a separate process, runs as a server, can this be generated/managed in Python with "zero configuration" on the part of the user, for the sake of deploying a desktop app based on this.
2) Does the database data etc get stored on disk.
SO that is it!
No, you can't embedd ArangoDB in the way you embedd SQLite.
ArangoDB offers the Foxx framework, which you can use to implement RESTfull microservices in JavaScript close to the database core like you would use python with SQLite. However, with AQL ArangoDB also offers a query language as SQLite does with sql.
There are currently several python drivers available that grant you access to ArangoDB from python in a compfortable manner.
The ArangoDB download page offers several packages, which you could use to deploy ArangoDB alongside your app. We offer a windows zip package that you could install by yourselves without user interaction; For linux distributions you'd probably want to use the respective package for that distribution. Easy deployability is one of our core goals.
Regarding the database and your data itself, this gets persisted to disk. This works via memory mapped files. However, the index and other structures are built up during the startup, which is why we refer to ourselves as mostly in memory.
Regular access to ArangoDB (and foxx) is done via the http interface and you get json documents as response. The drivers abstract that interface for you. If you implement foxx apps, you may need to formulate requests on your own.
ArangoDB Datafiles aren't intended to be moved across machines; though it may work as long as you have the same OS & Architectures on both sides. The proper way of doing this is to use ArangoDump on the first machine and ArangoRestore on the second. These are mostly json inside (one json document per line) so they're portable and even simple to load in python - you could even directly access the dump facility from python, and prepare an email for the user with the content.
The most sustainable way of running ArangoDB would be as a service; please note that you may need elevated privileges to register & re/start new services in Windows. The service then binds a tcp port, which you may access from other nodes in the network.

Membase can someone explain the idea behind their technology

It is fourth day already since I've started diving into CouchDB specifically Membase (Couchbase), Membase seems really interesting technology for me due to simplicity of administration, their interface is as magical as informal and simple. The way you add/remove buckets is just fun.
Unfortunately I didn't managed to launch their .NET client on Mac OS X (on Windows it worked fine) and also couldn't find out the way to perform Map/Reduce queries so it seemed that Membase Server technology is little simpler then pure CouchDB. Anyway everything changed until recently I've stumbled upon the diagram that describes their technology:
The Image is explained here
It seems that "Couchbase server (Currently Membase Server)" plays role of some sort of Master database which isn't accessed directly, and also there is "Couchbase Single Server" which plays the role of client database which has all the features of CouchDB (such as Map/Reduce queries)
If so then how is "CouchSync" is performed? Is it possible to perform this "CouchSync" from code?
Before I describe to you how CouchSync works I think it would be beneficial for me to describe how the Couchbase product history evolved. This will make things more clear. About a year ago, Membase Server was first released. The idea behind Membase Server was to provide memcached with persistence (the persistence layer was sqlite) and simple to use clustering technology. Then about 6 months ago the companies Membase and CouchOne merged to form Couchbase. Directly after the merger Couchbase continued to provide Membase Server, but now also provided Couchbase Single Server. Couchbase Single Server is essentially CouchDB with GeoCouch packaged in by default along with many major performance improvements. On July 29th, 2011 Couchbase announced a developer preview of the first version of Couchbase Server. Couchbase Server is the combination of Couchbase Single Server and Membase. Basically what Couchbase did was replace sqlite with CouchDB as the persistence engine. So this basically caused the product to go from being a key-value store to a document store database.
So what is CouchSync?
CouchSync is basically what Couchbase is calling CouchDB replication. It is very simple to setup in both Couchbase Server, Couchbase Single Server and in CouchDB. All it is is a changes feed that is streamed from one server to another.
A note on using Membase. Since Membase doesn't provide any of the CouchDB support it doesn't actually fit into this diagram and therfore doesn't support CouchSync. You will actually want to look at the developer preview of Couchbase Server since this product has both Membase and CouchDB features. In the meantime if you are looking for something more stable to test then take a look at Couchbase Single Server as it will be able to give you a feel for some of the features (like CouchSync) that are in Couchbase Server
Also, the point of this diagram is to show that you can do CouchSync across the entire Couchbase product line. You don't need to go through Couchbase Single Server to do CouchSync to Couchbase Mobile. You can do CouchSync directly from Couchbase Server.
Is it possible to perform CouchSync from code?
No. It's easier than that. You set it up in the web ui.
Hope that helps.
[EDIT]:
This diagram is now outdated. Couchbase the company no longer supports Couchbase Single Server (which is it's version of CouchDB). The CouchSync feature will now sync directly with Couchbase server.

Resources