QurateInc / vue-pouch-db

Vue Pouch DB is a VueJS Plugin that binds PouchDB with Vue and keeps a synchronised state with the database. Has support for Mango queries which are processed locally within the VuePouchDB state.
MIT License
126 stars 14 forks source link

Is sync two way? #6

Closed eimajenthat closed 6 years ago

eimajenthat commented 7 years ago

I'm populating a series of form fields from mapQueries. The fields populate fine, and the computed fields I have which use them update automatically. But the VuePouchDB's onChange event never fires, and the change isn't persisted after refresh. Do I have to send the update to PouchDB myself (ie. one way sync)? Or is there possibly an error somewhere?

sadiqevani commented 6 years ago

Hey @eimajenthat,

Yes the library is 2 way sync, but the problem which i've faced as well is dependent on the database configuration.

To throw the onChange event, CouchDB db when initialized need to be configured and you have to set a filter.

// 'projects' key -> Database Name, ex: couchdb.com/projects
  projects: {
    // PouchDB.sync Options
    sync: {
      push: {
        // config for push
      },
      pull: {
        filter: 'projects/by_user',
        query_params: { "name": "sadi" }
      }
    }