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

Uncaught (in promise) TypeError: t.onComplete is not a function #7

Closed dranzd closed 6 years ago

dranzd commented 6 years ago

I'm using this package on creating a desktop app using electron and electron-vue. Everything is working fine but I'm getting an error when retrieving the database using the $bucket when I don't provide the onComplete property in the bucket configuration.

Below is the sample error I'm getting:

/project/electron/app/node_modules/vue-pouch-db/dist/index.js:1 Uncaught (in promise) TypeError: t.onComplete is not a function
    at ve.<anonymous> (/project/electron/app/node_modules/vue-pouch-db/dist/index.js:1)
    at ve.n.emit (/project/electron/app/node_modules/vue-pouch-db/dist/index.js:1)
    at /project/electron/app/node_modules/vue-pouch-db/dist/index.js:1
    at /project/electron/app/node_modules/vue-pouch-db/dist/index.js:1
    at /project/electron/app/node_modules/vue-pouch-db/dist/index.js:1
    at /project/electron/app/node_modules/vue-pouch-db/dist/index.js:1
    at <anonymous>
(anonymous) @   /project/electron/app/node_modules/vue-pouch-db/dist/index.js:1
n.emit  @   /project/electron/app/node_modules/vue-pouch-db/dist/index.js:1
(anonymous) @   /project/electron/app/node_modules/vue-pouch-db/dist/index.js:1
(anonymous) @   /project/electron/app/node_modules/vue-pouch-db/dist/index.js:1
(anonymous) @   /project/electron/app/node_modules/vue-pouch-db/dist/index.js:1
(anonymous) @   /project/electron/app/node_modules/vue-pouch-db/dist/index.js:1

Tried to debug it and the problem seems to be around this line https://github.com/QurateInc/vue-pouch-db/blob/71311a069857ea67593beea8e0c72852af80e73b/src/index.js#L179

Is it correct that the line below uses ||

return config.onComplete || config.onComplete(complete);

or should it use &&?

return config.onComplete && config.onComplete(complete);

If that was a typo, I would be happy to provide a PR.

sadiqevani commented 6 years ago

Hey @dranzd,

Seems that should be the case, probably i've missed that.

Please send a pull-request and I will push the fix and publish on npm.

Regards Sadi

dranzd commented 6 years ago

Hi @sadiqevani,

Thanks for confirming that.

I am unable to fix the issue as my fresh installation's test keeps on failing saying that

Error: Invalid Adapter: undefined

If this is not expected and the test on your end passes, I don't think I can send a PR as I'm stuck with that part. I've tried to debug it but I'm unable to find the issue. My JS skill is very basic and that's probably one of the issue.

If it's an easy fix on your end I won't mind if you push the fix. If not, please point me to the right direction to make that test pass and I'll try to send a PR.

Thanks, Dranzd

sadiqevani commented 6 years ago

@dranzd Done.

Let me know if this will fix the issue.

Regards Sadi

dranzd commented 6 years ago

@sadiqevani That fixes the issue. Thank you!