Skip to content

itsmebhavin/angular-cli-pouchdb-couchdb

Repository files navigation

AngularCli-Pouchdb-CouchDB

This project was generated with Angular CLI version 1.2.7.

Development server

Run ng serve for a dev server. Navigate to http:https://localhost:4200/. The app will automatically reload if you change any of the source files.

Code scaffolding

Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module.

Build

Run ng build to build the project. The build artifacts will be stored in the dist/ directory. Use the -prod flag for a production build.

Running unit tests

Run ng test to execute the unit tests via Karma.

Running end-to-end tests

Run ng e2e to execute the end-to-end tests via Protractor. Before running the tests make sure you are serving the app via ng serve.

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI README.

Another strategy is to use one-db-per-user, but add a server-side process to occasionally dump user databases into some global database. E.g. here is a simple Node app:

var Promise = require('bluebird');
var request = Promise.promisifyAll(require('request'));
function syncEverythingToGlobalDB() {
  return request.getAsync('http:https://localhost:5984/_all_dbs').then(function (dbNames) {
    // find your user databases, however you named them
    var userDBs = dbNames.filter(function (x) { return x.indexOf('userdb') === 0; });
    return Promise.all(userDBs.map(function (userDB) {
        return request.postAsync({
          url: 'http:https://localhost:5984/_replicate',
          json: {source: 'http:https://localhost:5984/' + userDB, target: 'http:https://localhost:5984/globaldb'}
       });
  });
}
// do it every hour
setInterval(syncEverythingToGlobalDB, 3600000);
Notice I recommend using pure CouchDB for this because then you're using CouchDB's replicator. If you used PouchDB's replicator, then you'd have a lot of Node EventEmitters in one process and it would probably be inefficient; CouchDB is much better at handling many simultaneous replications. Edit: heck, you could just use CouchDB's continuous replication instead of doing it in a setInterval.

Author

  • This sample i have made only for my knowledge purpose and no claiming as original owner of it.
  • original code from [ https://github.com/timbophillips ] https://github.com/timbophillips/angular-cli-pouchdb

About

Angular 6 Cli based project for PouchDB and CouchDB setup

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published