Update returning with some relation

As the title says I am updating an object using this syntax:

const idToUpdate = "someId";
const newEvent = {...};
// event table has one-to-one relationship with table cost
const updatedEvent = await db.update(eventTable).set(newEvent).where(eq(eventTable.id, idToUpdate)).returning();

return updatedEvent;


is it possible for returning to return the update object with some relation, or would I need to fetch the object from the database in a separate query?

// something like this
const idToUpdate = "someId";
const newEvent = {...};
await db.update(eventTable).set(newEvent).where(eq(eventTable.id, idToUpdate));

// fetch the updated eventTable entry afterwards with it's cost relation
return await db.query.eventTable.findFirst({where: eq(eventTable.id, idToUpdate), with: {cost: true}});
Was this page helpful?