postgres-meta icon indicating copy to clipboard operation
postgres-meta copied to clipboard

Support batch `POST` (for columns for starters)

Open soedirgo opened this issue 2 years ago • 4 comments

Feature request

Is your feature request related to a problem? Please describe.

Creating a table with multiple columns is pretty slow. Supporting batch POST would save us a couple round trips and remedy that.

Describe the solution you'd like

Make POST accept a list of objects in addition to a single object. e.g.:

POST /columns
[
  { "table_id": 123456, "name": "c1", "type": "text" },
  { "table_id": 123456, "name": "c2", "type": "text" }
]

soedirgo avatar Feb 16 '22 02:02 soedirgo

@soedirgo I'd like to take a crack at it. I understand that we need to support both object and array of objects in POST body of /columns, let me know if there anything else i need to be aware before starting.

mahendraHegde avatar Sep 04 '23 22:09 mahendraHegde

Go for it @mahendraHegde!

we need to support both object and array of objects in POST body of /columns

Yup, ideally we also do the batch create in one db query, so we might also need to modify PostgresMetaColumns in lib (instead of just the server)

soedirgo avatar Sep 05 '23 06:09 soedirgo

@soedirgo yes makes sense i will modify the PostgresMetaColumns.create to accept the array and return array. How ever i have a doubt, since each object of the array will have table_id, so should we assume every row for the same table or are we supposed to support multiple table alter as well?

mahendraHegde avatar Sep 05 '23 13:09 mahendraHegde

@soedirgo i have made the changes for single table batch update, since its my 1st contribution to this repo plz give your feedback, i will add & fix tests meanwhile.

mahendraHegde avatar Sep 05 '23 22:09 mahendraHegde