Giter Club home page Giter Club logo

pouchdb-angular2's Introduction

PouchDB, Angular 2, and Couchbase Example

Example project for synchronizing documents between platforms and Couchbase with only Angular 2 and PouchDB.

The Requirements

This project depends on the following dependencies in order to be successful:

  • Node.js 4.0+
  • Angular 2 CLI
  • Couchbase Sync Gateway

To develop Angular 2 applications you need the Angular CLI which is downloadable via the Node Package Manager (NPM) found in Node.js. For synchronization at least one Couchbase Sync Gateway instance must be available.

Installation and Configuration

Download the project from GitHub and execute the following to download all of the Angular 2 project dependencies:

npm install

With the dependencies installed, use launch Sync Gateway with the sync-gateway-config.json configuration file found at the root of the project.

In the project's src/app/app.component.ts file, change the hostname to match that of your Sync Gateway instance.

The project can be sampled by executing:

ng serve

The above command will serve the application at http://www.localhost:4200.

Resources

Couchbase - http://www.couchbase.com

PouchDB - https://pouchdb.com

Angular 2 - https://angular.io

pouchdb-angular2's People

Contributors

nraboy avatar angular-cli avatar

Stargazers

Yared Dessalk avatar David McColl avatar Chopper Lee avatar Jon Repp avatar Darius Pelonia avatar Leland Smith avatar Martin Reus avatar  avatar Marco avatar Vadym Parakonnyi avatar Sergey Romanchuk avatar zlx avatar Harlan Gomes Nascimento avatar Prashanth Karnam avatar socialcode-rob1 avatar Erice Yang avatar Michl Ritter avatar Beau Watson avatar Fabian Daugs avatar Daniil Kolesnik avatar  avatar

Watchers

Sergey Avseyev avatar Steve Yen avatar Thuan Nguyen avatar Sarath Lakshman avatar  avatar  avatar Mike Wiederhold avatar Jeffry Morris avatar Laurent Doguin avatar Pasin Suriyentrakorn avatar Abhishek Singh avatar James Cloos avatar Dean Proctor avatar Dipti Borkar avatar Alex Ma avatar Brett Lawson avatar Wayne Siu avatar Sundar Sridharan avatar  avatar  avatar Sriram Ganesan avatar  avatar Jim Walker avatar Dan Owen avatar Manu Dhundi avatar Andrew Reslan avatar  avatar  avatar vickiezeng avatar Muragijimana avatar Couchbase Robot avatar  avatar Adam Fraser avatar Brian Williams avatar  avatar  avatar Michael Kwok avatar Keshav Murthy avatar Laura Czajkowski avatar  avatar  avatar

pouchdb-angular2's Issues

Error ng serve

Hello I have this error:
Version of @angular/compiler-cli needs to be 2.3.1 or greater. Current version is "undefined".

@angular/cli: 1.2.0 node: 6.11.0 os: darwin x64 @angular/common: 2.2.3 @angular/compiler: 2.2.3 @angular/core: 2.2.3 @angular/forms: 2.2.3 @angular/http: 2.2.3 @angular/platform-browser: 2.2.3 @angular/platform-browser-dynamic: 2.2.3 @angular/router: 3.2.3 @angular/cli: 1.2.0 @angular/compiler-cli: 2.2.3

Can't find module

I just run the npm install and ng serve
but when I run the ng serve
I get this error;

Cannot find module 'webpack/lib/dependencies/ContextElementDependency'
Error: Cannot find module 'webpack/lib/dependencies/ContextElementDependency'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object. (/Volumes/Work/Client/Devxy/pouchdb-angular2/node_modules/@ngtools/webpack/src/plugin.js:8:34)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)

What can I do?
I will be appreciate if anyone help me. :)

Sync with sync gateway does not work.

When I create data from a mobile device data are able to come on the desktop which is written in angular but data are written in angular is not able to be seen on mobile, to me, this is a sync issue.

import { Component, OnInit, NgZone } from '@angular/core';
import { PouchDBService } from "./pouchdb.service";

import * as PouchDB from 'pouchdb/dist/pouchdb';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {


  public people: Array<any>;
  public form: any;

  public constructor(private database: PouchDBService, private zone: NgZone) {
    this.people = [];
    this.form = {
      "username": "",
      "firstname": "",
      "lastname": ""
    }
  }

  public ngOnInit() {
    PouchDB.sync('main', 'http://localhost:4985/main', {
      password: 'password',
      user: 'admin',
      live: true,
      retry: true,
      continous: true,
      filter: "sync_gateway/bychannel",
      query_params: { "channels": ['43'] },
    }).on('change', (info: any) => {
      console.log("sync change:", info)
    }).on('paused', (err: any) => {
      console.log("sync paused", err)
    }).on('active', () => {
      console.log("sync active")
    }).on('denied', (err: any) => {
      console.log('denied', err);
    }).on('complete', (info: any) => {
      console.log("sync complete")
    }).on('error', (err) => {
      console.log("sync error", err)
    });
    this.database.getChangeListener().subscribe(data => {
      for (let i = 0; i < data.change.docs.length; i++) {
        this.zone.run(() => {
          this.people.push(data.change.docs[i]);
        });
      }
    });
    this.database.fetch().then(result => {
      this.people = [];
      for (let i = 0; i < result.rows.length; i++) {
        this.people.push(result.rows[i].doc);
      }
    }, error => {
      console.error(error);
    });
  }

  public insert() {

    if (this.form.username && this.form.firstname && this.form.lastname) {
      this.database.put(this.form.username, this.form);
      this.form = {
        "username": "",
        "firstname": "",
        "lastname": ""
      }
    }
  }

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.