redgeoff / delta-pouch

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

Document update question #67

Open evgeniylissin opened 7 years ago

evgeniylissin commented 7 years ago

Hello, Geoff. First of all thanks for your project. I have a couple of questions and hope that you will help us to continue using your module. I am checking this example: http://redgeoff.github.io/delta-pouch/examples/profile/?iris

  1. I set the "name" field to "name1", click "save" - the result is 1 record in database with "name" set to "name1".
  2. I set the "name" field to "name2", click "save" - the result is 2 records in database, first has "name" set to "name1", second has "name" set to "name2". Now if I query for the documents I will have 2 documents, but I expect to have 1 document with the "name" set to "name2". How can I achieve this? Calling the delta-pouch's method all() is not convinient because if I have 1000 profiles in the database, and I need to get one by id, I need then to get all of them and then loop through the result. If I run delta-pouch's method cleanup() - then I have 1 record in database with "name" set to "name1", so the result is no changes in the database made. But it is not what we expect.

So shortly our question is following:

  1. Run db.save({_id: 'record1', title: 'test1'}).
  2. Run db.save({$id: 'record1', title: 'title1 updated'}). Is it possible to get the document by Id 'record1' without calling the all() method and then looping through the result? Does the delta-pouch merges the records then (maybe using cron?) so we have 1 record in database with title "title1 updated"?

Thank you in advance, Eugene