How Can I Pass an Array to a Server Action to Write to the Database?

I am creating a booking form. It can manage up to 6 attendees, and each attendee can be asked any number of questions.

I want to find the most efficient way to write the question responses to the database. The responses have the following fields:

contact_id (integer)
question_id (integer)
response (text paragraph including line breaks)
comment  (text paragraph including line breaks)
various number fields (integer)

and I expect to have 10-100 individual responses which need writing to the database as individual rows to a table called responses.

I have been planning to store the responses on the client side in a Data Store ds_responses as they are entered by the user.

I would like to minimise the amount of database resources that are used in getting this done.

These seem to be my options, along with some questions:

  1. Write a flow that repeats through the records in the ds_responses Data Store and calls a server action to save each response individually.
    This I can do but seems expensive in terms of server and database usage.

  2. Pass the entire contents of the ds_responses Data Store to a single server action call and then either repeat through the records or send the whole record set to a stored procedure.
    This seems more efficient.

QUESTION - How can I pass the entire contents of the ds_responses Data Store in one go? Can I do it in some way via JSON? What Wappler feature would I use to do this?

Best wishes,
Antony.

Community Page
Last updated: