#query(on:) and .filter() - No exact matches in call

1 messages · Page 1 of 1 (latest)

amber briar
#

I am trying to make this query work:

 let email = try req.content.get(String.self, at: "email")
        return User.query(on: req.db)
            .filter(\User.$email.value == email)

I get two errors:

  • Binary operator '==' cannot be applied to operands of type 'KeyPath<User, FieldProperty<User, String>>' and 'String'
  • No exact matches in call to instance method 'filter'
rain breach
#
let email = try req.content.get(String.self, at: "email")

return try await User.query(on: req.db)
           .filter(\.$email == email)
           .first()