How can I update an entire collection by sending array of documents?

Hello. I have the following code:

static async updateById (id, update = {}) {
    const devices = await DeviceModel.find();
    const deviceIndex = devices.findIndex(d => d.id === id)
    if (deviceIndex === -1) throw new Error('device not found')

    devices[deviceIndex] = update;
    await Device.db.update('devices', devices)
  }

What I want to know is that to put on the last line of the function. I need to replace the “Device.db.update(‘devices’, devices)” with actual working code.

What I’m trying to do is overwrite the current collection with a new array of documents.

Correcting my typos: “What I want to know is WHAT to put on the last line of the function”.

What I’m trying to do is overwrite the current collection with a new array of documents (with one specific document updated with the js object received as a parameter, as seen in the code.).