pouch-vue icon indicating copy to clipboard operation
pouch-vue copied to clipboard

Data are not loaded

Open iBobik opened this issue 5 years ago • 4 comments

I initialize app like this:

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './registerServiceWorker'
import PouchVue from 'pouch-vue';
import PouchFind from 'pouchdb-find'
import PouchLiveFind from 'pouchdb-live-find'

Vue.config.productionTip = false

import PouchDB from 'pouchdb-browser'
PouchDB.plugin(PouchFind);
PouchDB.plugin(PouchLiveFind);

Vue.use(PouchVue, {
  pouch: PouchDB,
  defaultDB: 'pos'
});

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')

My component then tries to load data:

<script>
export default {
  pouch: {
    bill() {
      return {
        selector: {_id: "bill/" + this.$route.params.bill_id},
        first: true
      }
    },
    all() {
      return {}
    }
  },
  methods: {
    debug (event) {
      this.$pouch.get("bill/123").then(d => console.log(d));
      console.log(this);
    }
  }
}
</script>

<template>
  <div>
    <button @click="debug">debug</button>
  </div>
</template>

When I click on the debug button the first line ($pouch.get) correctly loads document from database.

But loading of the same object by pouch config does not work - this.bill and this.all are empty arrays.

What did I do wrong?

Versions: "pouch-vue": "0.3.4", "pouchdb-browser": "7.1.1", "pouchdb-find": "7.1.1", "pouchdb-live-find": "0.4.0", "vue": "2.6.10",

iBobik avatar Sep 15 '19 22:09 iBobik

In console there are also this messages after start:

[HMR] Waiting for update signal from WDS... log.js:24 db.type() is deprecated and will be removed in a future version of PouchDB 2 index-browser.es.js:450 TypeError: db.logIn is not a function 2 app.js line 3091 > eval:417:28

iBobik avatar Sep 15 '19 22:09 iBobik

Might be a bug, maybe @assemblethis can elaborate?

MDSLKTR avatar Oct 31 '19 16:10 MDSLKTR

Probably the same problem as https://github.com/MDSLKTR/pouch-vue/issues/31. See here for a fix

MDSLKTR avatar Oct 31 '19 16:10 MDSLKTR

TypeError: db.logIn is not a function

This issue is related to the call to login() in the watcher which then calls db.logIn (pouchdb-authentication). It doesn't make sense to do this, it assumes we're using pouchdb-authentication and none of the other calls to makeInstance are followed by login().

https://github.com/MDSLKTR/pouch-vue/blob/0b5c57a6fbc32c4e77cdb051c407a9f157716f97/src/index.js#L804-L810

I'll remove the line in PR #39. It's a relic from the original vue-pouch project and in the vue-pouch project there is a check beforehand to see whether or not auth setup:

https://github.com/buhrmi/vue-pouch/blob/c1787f4f3f5ed327802946a698c06610d8330c05/index.js#L193

assemblethis avatar Dec 04 '19 04:12 assemblethis