SiaqodbCloud is a RESTful service through which you can synchronize Siaqodb from client side( Windows, WindowsStore, Xamarin) with a server side NoSQL database like CouchDB or MongoDB.
C# JavaScript CSS ASP
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitattributes
.gitignore
LICENSE
README.md

README.md

SiaqodbCloud

SiaqodbCloud is a RESTful web service through which you can synchronize Siaqodb from client side (Windows, WindowsStore, Xamarin) with a server side NoSQL database like MongoDB or CouchDB.

Documentation

For the most up-to-date documentation, please refer to the Siaqodb documentation here: (http://siaqodb.com/docs/Synchronization-SiaqodbCloud)

MongoDB

MongoDB - you can download it from here ( min version 3.2.X), install it and then create a config file(eq: mongo.cfg) that looks something like this:

systemLog:
    destination: file
    path: c:\data\log\mongod.log
storage:
    dbPath: c:\data\db
replication:
   oplogSizeMB: 100
   replSetName: rs0

Start mongod with this config(example on Windows: "C:\mongodb\bin\mongod.exe" --config "C:\mongodb\mongo.cfg" ). The important section in the above config is the 'replication' section which will enable MongoDB to store all changes in oplog.rs collection. The entire Sync process relies on Mongo's oplog. After MongoDB server is started, start mongo shell and initialize replica set on 'local' database:

>use local
>rs.initiate()

now the collection 'oplog.rs' should be created on 'local' database.

Then create a database called 'siaqodb'.(If you preffer another name, you can change it in src\Repository\MongoDB\MongoDBRepo.cs). Then, inside the database created, create 2 collections: 'sys_accesskeys' and 'sys_synclog'. (The names can be changed also in \src\Repository\CouchDB\MongoDBRepo.cs ).

CouchDB

CouchDB - you can download it from here ( min version 1.6.1), install it and then create 2 databases: 'sys_accesskeys' and 'sys_synclog'. (The names can be changed in \src\Repository\CouchDB\CouchDBRepo.cs ).

CouchDB uses HTTP protocol, so after the installation, go to \src\Repository\CouchDB\CouchDBRepo.cs and modify the default CouchDB URL:

  private const string DbServerUrl = @"http://127.0.0.1:5984/";

with your own.

Authentication

Requests to SiaqodbCloud service are signed with a HMAC-SHA256 signature. Client code needs 'access_key_id' (which is public and included in the header of the request) and 'secret_key' which is used to build HMAC-SHA256 signature. The 'secret_key' must be provided in the client app but it's never transmitted. 'access_key_id' and 'secret_key' should be stored in sys_accesskeys database/collection. Example of a JSON record stored in CouchDB database or MongoDB collection called 'sys_accesskeys':

{
   "_id": "3ba69b5835dgdb308766b4756b00079a",
   "secretkey": "4362kljh63k4599hhgm"
}

Siaqodb Sync Example

Once you have the setup ready and the WebAPI running, you can Sync Siaqodb with MongoDB or CouchDB. You can choose the backend db(MongoDB or CouchDB) by modifying Repository/RepositoryFactory.cs :

public static IRepository GetRepository()
        {
            
             return new MongoDB.MongoDBRepo();
            //return new CouchDB.CouchDBRepo();
        }

A Siaqodb bucket has as correspondent a collection in MongoDB and a database in CouchDB. So before the sync, be sure you have created those collections/databases at the server side. Example:

  using (SiaqodbSync syncContext = new SiaqodbSync("http://localhost:11735/v0/", 
  "3ba69b5835dgdb308766b4756b00079a", 
  "4362kljh63k4599hhgm"))
 {
    IBucket bucket = siaqodb.Documents["persons"];
    syncContext.Push(bucket);//push local changes to server
    syncContext.Pull(bucket);//pull server changes to client db
            
   }