Closed tommyku closed 7 years ago
Same problem. And here is my workaround:
import Hoodie from '@hoodie/client';
import PouchDB from 'pouchdb-browser';
const myPouch = PouchDB.defaults({
auto_compaction: true
});
const hoodie = new Hoodie({
url: window.location.origin,
PouchDB: myPouch
});
I don't include /hoodie/client.js
in my frontend code. Instead, I instantiate Hoodie myself, with PouchDB of custom defaults.
I could write the compaction code myself if
hoodie
object exposes the internal PouchDB instance
In fact it does, at hoodie.store.db
. Note that the instance is replaced each time a user signs in / signs out, as the database gets destroyed
I don't include
/hoodie/client.js
in my frontend code. Instead, I instantiate Hoodie myself, with PouchDB of custom defaults.
That is the way to do it for more sophisticated apps 👍
@gr2m Yeah hoodie.store.db
does expose the PouchDB instance with which I can manage the db directly.
@gnowoel Thanks! Your approach is clean and handy especially if I want to keep all configs at one place.
I wanted to compact my PouchDB database because my app starts taking too much storage.
I could write the compaction code myself if
hoodie
object exposes the internal PouchDB instance but it doesn't. I could also enableauto_compaction
on instantiation of PouchDB instance but it is insideget-api
which I can't access.Would it be better to enable
auto_compaction
by default inget-api
, let user pass in PouchDB constructor options to hoodie constructor, or expose the PouchDB instance?