Skip to content

Instance Method

decode(model:prefix:keyDecodingStrategy:userInfo:)

Decode an entire Decodable “model” type at once, optionally applying a prefix and/or SQLRowDecoder.KeyDecodingStrategy to the type’s coding keys.
func decode<D>(model type: D.Type, prefix: String? = nil, keyDecodingStrategy: SQLRowDecoder.KeyDecodingStrategy = .useDefaultKeys, userInfo: [CodingUserInfoKey : any Sendable] = [:]) throws -> D where D : Decodable

Parameters

type

The type to decode.

prefix

A prefix to discard from column names when looking up coding keys.

keyDecodingStrategy

A decoding strategy to use for coding keys.

userInfo

See userInfo.

Return Value

An instance of the decoded type.

Discussion

See SQLRowDecoder for additional details.

Most users should consider using all(decoding:prefix:keyDecodingStrategy:userInfo:) and/or first(decoding:prefix:keyDecodingStrategy:userInfo:) instead.