I added a new function to my vapor server to query a postgres database for appointments using a userID.
func getAppointmentsByResidentID(req: Request) throws -> EventLoopFuture<[Appointment]> {
let token = try req.auth.require(Token.self)
guard let userIDString = req.parameters.get("userID"),
let userID = UUID(uuidString: userIDString) else {
throw Abort(.badRequest)
}
return Appointment.query(on: req.db)
.filter(.$userID == userID)
.all()
}
I get the following error:
[ WARNING ] PSQLError(code: server, serverInfo: [sqlState: 42883, file: parse_oper.c, hint: No operator matches the given name and argument types. You might need to add explicit type casts., line: 647, message: operator does not exist: text = uuid, position: 721, routine: op_error, localizedSeverity: ERROR, severity: ERROR], triggeredFromRequestInFile: PostgresKit/PostgresDatabase+SQL.swift, line: 60, query: PostgresQuery(sql: SELECT “appointments”.”id” AS “appointments_id”, “appointments”.”userID” AS “appointments_userID”, “appointments”.”firstName” AS “appointments_firstName”, “appointments”.”lastName” AS “appointments_lastName”, “appointments”.”phoneNumber” AS “appointments_phoneNumber”, “appointments”.”date” AS “appointments_date”, “appointments”.”time” AS “appointments_time”, “appointments”.”house” AS “appointments_house”, “appointments”.”residentAddress” AS “appointments_residentAddress”, “appointments”.”addressOfAppt” AS “appointments_addressOfAppt”, “appointments”.”description” AS “appointments_description”, “appointments”.”hasRideScheduled” AS “appointments_hasRideScheduled” FROM “appointments” WHERE “appointments”.”userID” = $1, binds: [(****; UUID; format: binary)])) [request-id: 5FD0447F-581D-419C-B6E6-FE5AE011DFCD]
Any ideas on what might be causing this error and how to fix it?