To add or delete multiple records to a model at once

In the tutorial ,I found that vapor can save or delete only one record at once by using " return req) " for case of save the data and " .delete(on:req)" in case delete.

But ,Are there any way to add or delete the multiple records to a model at once?

I’m trying to use SQL command as following.
But I don’t know how to run this command in Vapor.

INSERT INTO table_name (column_list)
** (value_list_1),**
** (value_list_2),**
** …**
** (value_list_n);**

Appreciated if anyone could advice.

It look like “Flatten” mentioned in the tutorial can be solved my problem. ^^

@thammaporn Glad you fixed it! Cheers! :]

1 Like