upsert icon indicating copy to clipboard operation
upsert copied to clipboard

upsert bulk function

Open etcware opened this issue 7 years ago • 1 comments

I have a problem similar to https://stackoverflow.com/questions/44357946/update-more-than-one-document-in-a-loop and I tried to solve it as described in the last answer. But it doesn't work, because when the upsert diffFunc enter the external loop is ended and v1...v6 are valued by the last loop iteration. Is it possible to get the id value inside the upsert diffFunc? Do you can suggest any other solution? The last comment in the post is mine (Alessandra).

etcware avatar Nov 18 '17 07:11 etcware

Just faced this issue and did this:

Promise.all(notes.map(note => db.upsert(note.docId, doc => {
      doc.syncCursorId = syncCursorId
      return doc
})).then(results => console.log(results))

dperetti avatar Jul 10 '18 07:07 dperetti