Update with array of objects
How do I do an update with an array of object where I update multiple fields in the object. The examples I find are just updating one field in the row.
type StoreSpecialHours = {
storeID: StoreID;
day: Day;
dayOpen: DayOpen;
dayClose: DayClose;
}
openingHours: StoreSpecialHours[],
const storeHours = await db
.update(storespecialhours)
.set(openingHours)
.where(
and(
eq(storespecialhours.storeID, openingHours.storeID),
eq(storespecialhours.day, openingHours.day),
),
)
.returning({
storeID: storespecialhours.storeID,
day: storespecialhours.day,
dayOpen: storespecialhours.dayOpen,
dayClose: storespecialhours.dayClose,
})