upsert
upsert copied to clipboard
upsert bulk function
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).
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))