redgeoff / delta-pouch

Conflict-free collaborative editing for PouchDB
196 stars 13 forks source link

Can't delete() a whole doc #3

Closed nolanlawson closed 10 years ago

nolanlawson commented 10 years ago

Right now I can do

pouch.delete({foo: 'bar', $id: 'myid'});

And it will resolve the promise with success. However, 'myid' is not deleted - I need to pass in the string rather than the full doc.

It would be nice if the delete method checked whether the input was an object and then looked for an $id. Also if the $id doesn't exist in the object, it should probably throw an error.

redgeoff commented 10 years ago

You state However, 'myid' is not deleted. pouch.delete('myid') will create a new delta doc that with $deleted=true. This can then be handled using onCreate. Check out the Websites example. It's a little funky, but I don't have any better ideas for simplifying it yet.

Assuming that everything is working properly, then is your request that pouch.delete either take the full doc or just an id? Just want to clarify as the However, 'myid' is not deleted comment confused me.

nolanlawson commented 10 years ago

Sorry, yeah, I just mean it'd be nice if it accepted both an object and id. Only tripped me up because I was used to passing in the full doc to PouchDB's remove method.