Static Methodgrdb 7.1.0GRDB

including(all:)

Returns a request that fetches all records associated with each record in this request.

TableRecord+Association.swift:623
static func including<A>(all association: A) -> QueryInterfaceRequest<Self> where Self == A.OriginRowDecoder, A : AssociationToMany

For example, we can fetch authors along with their books:

struct Author: TableRecord, FetchableRecord, Decodable {
    static let books = hasMany(Book.self)
}
struct Book: TableRecord, FetchableRecord, Decodable { }

struct AuthorInfo: FetchableRecord, Decodable {
    var author: Author
    var books: [Book]
}

let authorInfos = try Author
    .including(all: Author.books)
    .asRequest(of: AuthorInfo.self)
    .fetchAll(db)