supabase / postgrest-dart

Dart client for PostgREST
https://supabase.com
MIT License
136 stars 38 forks source link

Bulk insert rows #34

Closed deepu closed 3 years ago

deepu commented 3 years ago

Bulk insert

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

Our requirement is a user selects a bunch of docs (around 50-70) assigns it to a topic and hits save button

When the user hits save button we need to save those 50+ docs to Postgres DB At once

Describe the solution you'd like

I would like a bulk insert call to which we pass an array and all of them gets inserted.

Describe alternatives you've considered

For now am looping over all docs and inserting each doc one by one .

But this method is prone to errors esp if the user navigates away or network drops after some docs

dshukertjr commented 3 years ago

Hi @deepu !

Actually, you can already do bulk insert with Supabase. You can take a look at the reference here to see how it works! https://supabase.io/docs/reference/javascript/insert#bulk-create

The reference shows a JavaScript example, but should work the same way with Dart as well.

Let me know if this fulfills what you are trying to achieve!

deepu commented 3 years ago

@dshukertjr

Thanks for quick reply.

Guess I somehow missed bulk insert while going through documentation.

I tried it and working well. Thanks a lot