jeremydaly / data-api-client

A "DocumentClient" for the Amazon Aurora Serverless Data API
MIT License
440 stars 60 forks source link

Feature Request: Support for returning uuid from batch INSERT #97

Open marracuene opened 3 years ago

marracuene commented 3 years ago

https://github.com/jeremydaly/data-api-client#retrieving-insert-ids says:

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.