novi / mysql-swift

A type safe MySQL client for Swift
MIT License
163 stars 40 forks source link

Support for inserting multiple rows in a single statement #62

Closed florianreinhart closed 6 years ago

florianreinhart commented 6 years ago

In node-mysql I can do something like this:

let users: [User] = [user1, user2, user3]
try connection.query("INSERT INTO User (id, name, age) VALUES ?", [users])

In mysql-swift I have to manually build the query string depending on the number of rows, e.g. "INSERT INTO User (id, name, age) VALUES (?,?,?), (?,?,?), (?,?,?)".

I could also be missing something. Is there another way to achieve this in mysql-swift?

novi commented 6 years ago

We already have the way to do multiple inserting (or bulk inserting) like this. But we have to convert models into QueryArray to do that.

florianreinhart commented 6 years ago

Thanks! That's better then my previous implementation.