Reputation: 83
I used the vapor in the postgresql ,I want to save a lot of data at once ,but I don't how to use postgresql transaction,Who can give an example.
Upvotes: 1
Views: 406
Reputation: 5421
If you are using Fluent (Vapor's database ORM with support for PostgresQL) then you simply use:
drop.database?.transaction { conn in
try modelToSave.makeQuery(conn).save()
try nextModelToSave.makeQuery(conn).save()
}
Upvotes: 2