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

Cool project! #5

Closed MichaelJCole closed 7 years ago

MichaelJCole commented 7 years ago

Hi, I checked out the readme and scanned the code, but didn't understand how to use it. What does it do? How does it work?

sadiqevani commented 7 years ago

Hey @MichaelJCole,

Its PouchDB integration for VueJS, i built it based on my needs. Might not work for everyone.

So, on the VuePouchDB.Bucket object, there are several reserved props. config, plugins and actions

Basically, on config you define the global configuration object that each CouchDB/PouchDB will have.

on plugins, you simply insert the PouchDB plugin, as shown in the example.

actions are just a placeholder for custom functions that you can use.

Now, the cool stuff comes now, any other property you define, is basically an instance of a Database in CouchDB/PouchDB.

Let say projects database, you can define local configuration for this database, let say pulling views, or you want this DB to be remote only.

By defining these databases before hand, we can cache them and have that single instance running throughout the run-time.

Also, you're not bound on creating these DBs with the config file, you can also call them with the specific function (this.$bucket.db())

or you can setup them through the component instance:

dbsetup: {
    // the database name
    // both keys can take a function
    // that is bound to the component
    // instance
    name: "dbname",
    // the config object
    // When a database is created the "options"
    // key is taken from the context and applied
    // to the database.
    // Note: does not work for already instantiated
    // databases.
    options: {}
  }
MichaelJCole commented 7 years ago

@sadiqevani Hey, thanks for the comment - helps a bunch!