MihaelIsaev/VaporCron

Example code doesn't seem to work

Closed this issue · 1 comments

I've just tried your cron package but for some reason I can't get it to work in the latest version of Vapor.

return container.requestPooledConnection(to: .mysql).flatMap { conn in
            // here you sould do whatever you want cause you already have a connection to database
            // it's just an example below
            return User.query(on: conn).all().flatMap { users in
                return users.map { user in
                    user.updatedAt = Date()
                    return user.save(on: conn).transform(to: Void.self)
                    }.flatten(on: container)
            }.always {
                // this is how to close taken pooled connection
                try? container.releasePooledConnection(conn, to: .mysql)
            }
        }

Gives an error:

Cannot convert return expression of type 'EventLoopFuture<Void.Type>' to return type 'EventLoopFuture<Void>'

I've fixed example code in readme, there should be .transform(to: ()) instead of .transform(to: Void.self).
@maximedegreve thank you! 🤝