Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using PouchDB with SQL Server and CouchDB

I know that PouchDB only works with CouchDB compatible servers. Is there a way to use SQL Server as a backend while maintaining its original schema?

I have a thought how to accomplish this but I am not entirely sure if it is feasible. Any answer that will lead this to fruition will be appreciated.

The way I see it can be done is by using CouchDB to store the sync metadata like revisions and all things needed for a successful sync. The actual latest data will then be stored on the SQL Server following its original schema.

To be able to accomplish this I need to create a CouchDB compatible server using my stack which is C#. This will act like a proxy in between CouchDB and PouchDB so I don't actually need to implement all methods. I will have to intercept certain methods that will allow me to keep SQL Server and CouchDB in sync (following business rules) on the server at the same time take advantage of CouchDB's sync capability over the SQL Server Data. With this in place I could also add a bunch of middleware I wish in the future.

Is this thing feasible? I know that express-pouchdb exist but it is just a CouchDB compatible server with a PouchDB backend. What I wanted is to make the CouchDB and SQL Server work together. If so, how should I go about it?

like image 937
bman Avatar asked Mar 24 '17 07:03

bman


People also ask

Why would you use PouchDB along with CouchDB?

CouchDB works well with modern web and mobile apps. PouchDB (local/client) enables applications to store data locally while offline, then synchronize it with CouchDB and compatible servers when the application is back online, keeping the user's data in sync no matter where they next login.

Is PouchDB a NoSQL?

PouchDB is a NoSQL database, meaning that you store unstructured documents rather than explicitly specifying a schema with rows, tables, and all that jazz.


1 Answers

Might sound like a crazy idea, but you can use PouchDB on the server and plug in an alternative storage adapter that uses SQL Server. That way you don't need to reimplement the replication logic (this is really hard), you can concentrate on the storage part.

Some pointers:

  • https://pouchdb.com/adapters.html
  • https://github.com/Level/leveldown
  • https://github.com/calvinmetcalf/sqldown
like image 87
Bernhard Gschwantner Avatar answered Oct 04 '22 22:10

Bernhard Gschwantner