与实例方法中无确切的匹配' filter'在蒸气中
我面临有关“过滤”函数的错误[Fluent的查询API |汽]。
我阅读了Vapor为此案提供的文档,看来语法很好。因此,我不知道确切的问题在哪里。
- 错误屏幕截图附加下面:
- 这是整个函数的代码段:
func login(req: Request) throws -> EventLoopFuture<String>
{
let userToLogin = try
req.content.decode(UserLogin.self)
print("user to login \(userToLogin)")
//Get user from DB
return User.query(on: req.db)
.filter( \.$email == userToLogin.email)
.first()
.unwrap(or: Abort(.notFound))
.flatMapThrowing { dbUser in
let verified = try dbUser.verify(password: userToLogin.password)
print("attempt verify password \(verified)")
if verified == false {
throw Abort(.unauthorized)
}
req.auth.login(dbUser)
let user = try req.auth.require(User.self)
return try user.generateToken(req.application)
}
}
I'm facing an error regarding 'filter' function [Fluent's query API | Vapor].
I read the documentation that´s provided by Vapor for this case and it seems the syntax is fine. Hence I've no idea where the exact issue is located.
- Error screenshot is attached below:
- Here is the code segment for the whole function:
func login(req: Request) throws -> EventLoopFuture<String>
{
let userToLogin = try
req.content.decode(UserLogin.self)
print("user to login \(userToLogin)")
//Get user from DB
return User.query(on: req.db)
.filter( \.$email == userToLogin.email)
.first()
.unwrap(or: Abort(.notFound))
.flatMapThrowing { dbUser in
let verified = try dbUser.verify(password: userToLogin.password)
print("attempt verify password \(verified)")
if verified == false {
throw Abort(.unauthorized)
}
req.auth.login(dbUser)
let user = try req.auth.require(User.self)
return try user.generateToken(req.application)
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题不是
filter
,而是==
需要重载。确保您的
文件中有。
The problem is not with
filter
, but with==
that needs to be overloaded.Make sure you have
in you file.