Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data are not loaded #33

Open
iBobik opened this issue Sep 15, 2019 · 4 comments
Open

Data are not loaded #33

iBobik opened this issue Sep 15, 2019 · 4 comments

Comments

@iBobik
Copy link

iBobik commented Sep 15, 2019

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
Copy link
Author

iBobik commented Sep 15, 2019

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

@MDSLKTR
Copy link
Owner

MDSLKTR commented Oct 31, 2019

Might be a bug, maybe @assemblethis can elaborate?

@MDSLKTR MDSLKTR added the bug label Oct 31, 2019
@MDSLKTR
Copy link
Owner

MDSLKTR commented Oct 31, 2019

Probably the same problem as #31. See here for a fix

@MDSLKTR MDSLKTR closed this as completed Oct 31, 2019
@MDSLKTR MDSLKTR reopened this Oct 31, 2019
@assemblethis
Copy link
Collaborator

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().

pouch-vue/src/index.js

Lines 804 to 810 in 0b5c57a

db = databaseParam;
} else if (typeof databaseParam === 'string') {
if (!databases[databaseParam]) {
makeInstance(databaseParam);
login(databases[databaseParam]);
}
db = databases[databaseParam];

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants