Skip to content

🍓SwifQLable: Implement convenient execute method

Pre-release
Pre-release
Compare
Choose a tag to compare
@MihaelIsaev MihaelIsaev released this 20 May 10:34
· 29 commits to master since this release

When you have only one complex query in route handler and it shouldn't be wrapped into transaction you could use this convenient method which will establish database connection by itself

func someComplexQueryHandler(_ req: Request) throws -> EventLoopFuture<[CustomResult]> {
    SwifQL

        /// your complex query here

        .execute(.psqlEnvironment, on: req)
        .all() // or explicit .all(decoding: CustomResult.self)
        // .first()  // or explicit .first(decoding: CustomResult.self)
        // .count()
}