In Vapor 3 I was able to get a newConnection to the database and call a raw sql query using this:
return request.withNewConnection(to: .mysql) { (con) -> EventLoopFuture<T> in
return con.raw(sql)...
}
Now that I'm migrating my code to Vapor 4 the function raw or withNewConnection is gone, what can I use to make a raw query.
Steps to reproduce
return request.withNewConnection(to: .mysql) { (con) -> EventLoopFuture<T> in
...
}
Error: Cannot infer contextual base in reference to member 'mysql' Value of type 'Request' has no member 'withNewConnection'
Expected behavior
Have a function inside request.db that let me get a new connection or run a raw query.
Environment
- Vapor Framework version: 4.7.1
- Vapor Toolbox version: vapor-beta
- OS version: macOS Catalina