Closed gr2m closed 9 years ago
@gr2m by "follow up", you mean after #31 has been merged, correct?
yes, exactly, it kind of depends on #31, that's why I added it
@gr2m, I am not sure this is compatible with the current implementation of events. In #31, I am using PouchDB events and afaik there is no way to stop PouchDB events from being triggered when you delete docs. The only operation I can find that won't trigger the events is destroying the db.
Maybe we need to rethink the whole events implementation if clear
is needed?
destroying the db sounds right to me for .clear()
. You'd call clear for example when you sign out of an account, you'd want to remove everything in the database and start with a clear state. Anything speaking against destroying the db on clear?
@nolanlawson if I remember correctly, there is some known issue with db.destroy()
, right? I'd love to hear your thoughts on adding a store.clear()
method that wouldn't trigger the delete
events on objects, if you have a moment
@gr2m Long-term, both destroy()
and calling remove()
for all documents should be stable, but in practice there are lots of issues with destroy()
due to race conditions in different implementations of IndexedDB. I'm hoping most of those will be ironed out once I (or someone) have implemented native secondary indexes, which are the source of most of those race conditions.
thanks @nolanlawson! What would you recommend for the time being? Should we silently delete all docs and do not call db.destroy()
at all?
Orrr, donno how to link issues with PRs ^^, so here is it https://github.com/hoodiehq/pouchdb-hoodie-api/pull/50
@toh82 add a closes #39
to the description of the PR. Once it gets merged, the related issue will be closed automagically :)
follow up for #31
We left out
api.clear()
from the scope of this plugin initially because we thought we wouldn't add events.api.clear()
is just likeapi.removeAll()
, but without triggering theadd
,update
,remove
andchange
events.It shouldn't be exposed for Modular Usage, just like
on
,one
andoff
UPDATE also add
clear
event, that only gets called whenapi.clear()
gets called and it finishes successfully