I am trying to query a postgres DB using the Fluent ORM and I'm attempting to filter a query based on it's parent class 'User' UUID value. The following code throws the error: Operator function '==' requires that 'UUID' conform to 'QueryableProperty'
func getItem(_ req: Request) throws -> EventLoopFuture<Scan> {
guard let user = req.auth.get(User.self) else {
throw Abort(.unauthorized)
}
return Item.query(on: req.db)
.filter(\.$user.id == user.id) // <- This is the line in question
.filter(\.itemID == req.parameters.get("itemID") ?? "")
.first()
.unwrap(or: Abort(.notFound))
}
Any idea how to perform a filter query based on a UUID?
Thank you in advance!