How can I get data result after updated?


I used Lucid like this.

const customer await Customer.query().where('id', id).update({username: 'admin'})

and then return customer the value I got is 1 but I want the result of data



The default behavior of your operation is to return the number of affected rows.
In your case, one row was affected, so you got 1.

You can get the related data by, for example, querying that row given its ID:

const customer = await Customer.find(id) // I suppose you have got the ID  from somewhere
1 Like


Hi @9wisit

As addition to begueradj I’d like to add, that in your current case you can also use merge() with save(). Merge merges new data to old model and save returns saved model

Scroll down a little from there

Update is mostly ment for bulk updates, not per ID

1 Like


and save returns saved model

@ McSneaky you are wrong.
According to this the save method returns a Boolean.

1 Like


Hi @Melchyore

You’r right, thnx for pointing that out :slight_smile:

It’s create() not save() that returns model

1 Like