pouchdb / upsert

PouchDB plugin for upsert() and putIfNotExists() functions
Apache License 2.0
149 stars 25 forks source link

Upsert without update function #64

Open indo-dev-0 opened 5 years ago

indo-dev-0 commented 5 years ago

It would be nice if I could just pass in a document and not worry about the update function: db.upsert(docId, diffFunc|doc [, callback]). I usually just want to overwrite the old document and this would be a nice ergonomic enhancement:

let doc = {id: "12345", foo: "baz"};
db.upsert(doc.id, (old) => {
  return doc;
});
//vs
db.upsert(doc.id, doc);