TypeError: Cannot read property ‘adapter’ of undefined in Batch


I am getting a weird error in CloudCode using a DB.Batch operation.

TypeError: Cannot read property ‘adapter’ of undefined. Below is my code, and it seems to fail on the forEach line

    const job = await DB.job.first();
    if (job) {
        const batch = new DB.Batch();
        const shutdowns = await job.shutdowns.toArray();
        await batch.execute();

Update your forEach to the following:

shutdowns.forEach((shutdown) => 

In the current setup, the batch.destroy will just give you a reference to the generic method and it is not tied to the specific batch.