redgeoff / delta-pouch

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

Getting a given object #41

Closed trokster closed 7 years ago

trokster commented 9 years ago

Hi,

Sorry stupid question maybe. How do you pull a given object from the DB ? Say I have an object with $id = 123, is there a method akin to get, or would I need to manually merge it from all changes ?

redgeoff commented 9 years ago

This is a good question. Currently, the only way to do this is to make a call to all() and get all the documents, e.g.

db.all().then(function (docs) {
  // docs is an "associate array" of docs
});

There are no plans to provide a get() function at this point.

ruud12 commented 5 years ago

Hello,

Is there a specific reason for not implementing the get() functionality? I am also looking for this functionality. I would simply propose to change the "all()" function to:

Code change in the all() function would be something like: return db.allDocs({include_docs: true, startkey: docID, endkey: docID+"_\ufff0"}).then(function (doc) {

Would this be an option and if yes, shall I make a pull request with the proposed changes? Thanks in advance!

redgeoff commented 5 years ago

Hey @ruud12! I think this is a good idea. Please name this new function get. I look forward to seeing the PR!