bulkWrite() not returning results in Atlas App Function

I am trying to process results of a bulkWrite operation within an Atlas function (javascript). I have tried multiple variations of try catch, awaiting, .then().catch().

The operation itself works great but no results are being fed back. I need to know the ids of the records that are updated vs inserted.

Here is the code as it currently stands:

  let result = await inst.bulkWrite(upsertJobs);

Any idea how to get the results data back from this function?

Hi @Rory_O_Brien,

Unfortunately, this is expected: the subset of operations supported in Functions doesn’t match the ones available in the drivers. More in detail, bulkWrite returns Promise<null>

1 Like

I am also trying to bulkWrite in App Services Function.
I tried to wrap it in a try catch transaction but even if I don’t match any documents there is no error produced to catch.

I don’t think it’s possible. See:

One option is to use keep a track of all the documents you insert and their ids instead of relying on the driver to generate and assign a random id. Or you could just upsert everything and then retrieve the ids.
Let me know if that helps.