-
findFromParameter(_:Asynchronouson: inTransaction: builder: ) Returns a
Modelthat will match the ID given in a named request parameter. For a route that has a parameter nameduserIDParam.paramString,User.findFromParameter(userIDParam, req)will get the value of the parameter and use that to fetch the user with that ID from the User table. Returns a failed future with an Abort error if: the parameter doesn’t exist, the parameter’s value can’t be made into an IDValue for the Model type, or no Model type with that ID was found in the database.Declaration
Swift
static func findFromParameter( _ param: PathComponent, on req: Request, inTransaction transaction: (any Database)? = nil, builder: ((QueryBuilder<Self>) -> Void)? = nil ) async throws -> SelfParameters
paramA PathComponent describing a path component of type .parameter
reqThe incoming request
Container, which provides theEventLoopon which the query must be run.transactionThe transaction to query the database in. If unset, uses req.db and doesn’t run the query in a transaction.
Return Value
[UUID]containing all the user’s associated IDs. -
findFromParameter(_:Asynchronouson: inTransaction: builder: ) Returns a
Modelthat will match the ID given in a named request parameter. For a route that has a “:userid” parameter,User.findFromParameter("userid", req)will return that user from the User table. Returns a failed future with an Abort error if: the parameter doesn’t exist, the parameter’s value can’t be made into an IDValue for the Model type, or no Model type with that ID was found in the database.Declaration
Swift
static func findFromParameter(_ param: String, on req: Request, inTransaction transaction: (any Database)? = nil, builder: ((QueryBuilder<Self>) -> Void)? = nil) async throws -> SelfParameters
paramThe name of a request parameter e.g. “user_id”
reqThe incoming request
Container, which provides theEventLoopon which the query must be run.transactionThe transaction to query the database in. If unset, uses req.db and doesn’t run the query in a transaction.
builderA block that runs during query construction; mostly lets callers add
.with()clauses to the query.Return Value
[UUID]containing all the user’s associated IDs.
View on GitHub