When inserting, updating, or deleting records via PostgREST, you can send the Prefer: return=representation header, which will return the object that was written. This is especially helpful when you create new records and need the id that was generated by the database. Currently, the promise returned by post, patch and delete is Promise<void>, but having a return such as Promise<{data: any}> would be great if the representation (or any of the specific columns specified via the query select=id syntax) would be available.
This would make it possible to get return values from PostgREST. Also, when you want to add support for stored procedures via the /rpc path, it would be easy, as you can use the same capabilities to return values from the stored procedure call.
🚀 Support Prefer: return=representation
When inserting, updating, or deleting records via PostgREST, you can send the
Prefer: return=representation
header, which will return the object that was written. This is especially helpful when you create new records and need the id that was generated by the database. Currently, the promise returned bypost
,patch
anddelete
isPromise<void>
, but having a return such asPromise<{data: any}>
would be great if the representation (or any of the specific columns specified via the queryselect=id
syntax) would be available.You can see more about the
Prefer
options here: http://postgrest.org/en/v7.0.0/api.html#insertions-updatesMotivation
Right now if I create a record, I am unable to get database generated columns, such as the id.
Example
Pitch
This would make it possible to get return values from PostgREST. Also, when you want to add support for stored procedures via the
/rpc
path, it would be easy, as you can use the same capabilities to return values from the stored procedure call.