You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Data API returns a generatedFields array that contains the value of auto-incrementing primary keys. If this value is returned, > the Data API Client will parse this and return it as the insertId. This also works for batch queries as well.
What about for generated UUID primary keys?
For example with a table like this:
CREATE TABLE test
(
id uuid primary key default uuid_generate_v4(),
country text not null,
name text
);
and an insert query like this:
`INSERT INTO test(country, name) VALUES(:country, :name)
Would it be possible access the generated uuid in the data-api-client result structure?
NOTE: using data-api-client with Postgres, one can append RETURNING id to the above INSERT statement, and then access the returned id field on the results.records structure, just as though it were a column returned by a SELECT statement. We are using this in production with single inserts and it works perfectly. However switching to batch inserts, the rows are still inserted but nothing is returned.
The text was updated successfully, but these errors were encountered:
https://github.com/jeremydaly/data-api-client#retrieving-insert-ids says:
What about for generated UUID primary keys?
For example with a table like this:
and an insert query like this:
Would it be possible access the generated uuid in the data-api-client result structure?
NOTE: using data-api-client with Postgres, one can append
RETURNING id
to the above INSERT statement, and then access the returnedid
field on the results.records structure, just as though it were a column returned by a SELECT statement. We are using this in production with single inserts and it works perfectly. However switching to batch inserts, the rows are still inserted but nothing is returned.The text was updated successfully, but these errors were encountered: