I think I'd prefer this in fewer lines:

```js
const rowId = result.insertId || result.row.id;
criteriaIds.push(rowId);
```