Skip to content

ModelClass.query().patch().where().returning('*') works differently than RECIPES #1008

@BrennanRoberts

Description

@BrennanRoberts

The "Update a single row by ID and return the updated Model instance in 1 query:" section of the Recipes doc shows the following operation returning a single record:

const jennifer = await Person
  .query()
  .patch({firstName: 'Jenn', lastName: 'Lawrence'})
  .where('id', 1234)
  .returning('*');

console.log(jennifer.updatedAt); // NOW()-ish
console.log(jennifer.firstName); // "Jenn"

In actuality, this seems to return a list of records, i.e.jennifer.firstName will be undefined.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions