Mysql LAST_INSERT_ID
wendyliga opened this issue · 2 comments
wendyliga commented
is there any LAST_INSERT_ID
equivalent on fluent mysql ?
tanner0101 commented
Fluent automatically fetches the last insert ID when you create a new model. If you're using the MySQL driver directly, there's an optional onMetadata
closure you can pass to get access to this and other query metadata: https://github.com/vapor/mysql-nio/blob/master/Sources/MySQLNIO/MySQLQueryCommand.swift#L13
wendyliga commented
@tanner0101 there's case when you want to insert to new table use latest inserted on other tables. it will be amazing if we could fetch the last inserted (auto increment) id.