pouchdb-community / pouchdb-all-dbs

allDbs() plugin for PouchDB
Apache License 2.0
29 stars 18 forks source link

So how do you use this client side? #21

Closed tohagan closed 8 years ago

tohagan commented 8 years ago

Sorry I'm using Angular and don't have require(). So how do I register this plugin?
I expected something like PouchDB.plugin(DropAll); But what don't see a $window.DropAll (or similar) declared to do this.

Following your README instructions I find PouchDB.allDbs is undefined.

nolanlawson commented 8 years ago

If you are using script tags, then you need to attach PouchDB to the window object before using. Otherwise if you are using Browserify/webpack/etc. then you can do require('pouchdb').plugin(require('pouchdb-all-dbs')). Sorry it's not any easier.

tohagan commented 8 years ago

Unfortunately I'm using Angular which does not have require() defined AFAIK. I eventually avoided using this API by tracking db's I've created/removed another way - same concept tho. Thanks for the idea.

nolanlawson commented 8 years ago

Sorry about that! In the future please know that you can always convert from require/Browserify/Webpack Land into Script Land by using a tool like wzrd.in. E.g.: http://wzrd.in/standalone/pouchdb-all-dbs

Then you just take that script, and you now have a global window.pouchdbAllDbs object, which you can attach to PouchDB using PouchDB.plugin(pouchdbAllDbs). Hope that helps!