returnDocument¶
returnDocument decides which version of the row an update by id or a replace by id sends back : the row after the change (the default) or the row before it.
| Value | The response holds |
|---|---|
after (default) |
The row as it is now, with the fields you changed. |
before |
The row as it was, so you can show or log what changed. The update happens all the same. |
Response with returnDocument=before
{
"success": true,
"statusCode": 200,
"data": { "customer_id": 1, "first_name": "Bob", "last_name": "Lin", "pincode": 382345 }
}
- It only changes the response, never what is written.
- It works with
selectanddeep: both apply to the version returned. - From code :
g.sys.db.updateById({ ..., returnDocument: 'before' }).