MDSLKTR / pouch-vue

Pouchdb bindings for Vue.js
MIT License
90 stars 17 forks source link

Error: Missing/invalid DB name #18

Closed tnaffh closed 5 years ago

tnaffh commented 5 years ago

Calling this.$pouch.info() in my vue component givesme an error Error: Missing/invalid DB name because I didnt specify the db name.

My question is, is the db name not set when I did this bellow?

ue.use(PouchVue, {
  pouch: PouchDB,    // optional if `PouchDB` is available on the global object
  defaultDB: 'myDB',  // this is used as a default connect/disconnect database
  optionDB: {}, // this is used to include a custom fetch() method (see TypeScript example)
  /*debug: '*' */// optional - See `https://pouchdb.com/api.html#debug_mode` for valid settings (will be a separate Plugin in PouchDB 7.0)
});

Do I have to specify the db name everytime I call $pouch? or am I missing something?

assemblethis commented 5 years ago

There's inconsistency in the API when it comes to default values supplied for the db parameter. Some methods supply a default value:

disconnect(db = databases[defaultDB])

others don't:

destroy(db)

Let me test a fix for this. I can't see a rationale for not supplying the default value of defaultDB for all methods but maybe one will come to me.

MDSLKTR commented 5 years ago

I think it's just inconsistency. I also see no reason to not always fall back to the defaultDB.

MDSLKTR commented 5 years ago

Hey @tnaffh. A new version 0.3.0 is released reworking this inconistency thanks to @assemblethis. So .info() should now work with the defaultDB if no params are given. See: https://github.com/MDSLKTR/pouch-vue/blob/master/src/index.js#L682

MDSLKTR commented 5 years ago

I closed this since the issue should be resolved in the new version. Please reopen if anything doesn't work as expected.