Skip to content

🏀 Implement `requestConnection` method

Pre-release
Pre-release

Choose a tag to compare

@MihaelIsaev MihaelIsaev released this 06 Jun 13:41
· 1 commit to master since this release
2e9988f

Thanks to @YorkFieldX now we can use MySQLConnection in tests simply this way

// retrieve a connection
let connection = try application.mysql.requestConnection(to: .my_awesome_database).wait()

// execute any queries
let users = try SwifQL.select(User.table.*)
                      .from(User.table)
                      .execute(on: connection)
                      .all(decoding: User.self)
                      .wait()

// don't forget to close a connection
try connection.close().wait()

⚠️Use this way only in tests cause you can only close a connection but not return it back to a pool, so it may affect app performance.