Files
2022-11-09 08:57:09 +01:00

1 line
6.1 KiB
JSON

{"primaryContentSections":[{"kind":"declarations","declarations":[{"tokens":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"annotated"},{"kind":"text","text":"("},{"kind":"externalParam","text":"with"},{"kind":"text","text":" "},{"kind":"internalParam","text":"aggregates"},{"kind":"text","text":": ["},{"kind":"typeIdentifier","identifier":"doc:\/\/GRDB\/documentation\/GRDB\/AssociationAggregate","preciseIdentifier":"s:4GRDB20AssociationAggregateV","text":"AssociationAggregate"},{"kind":"text","text":"<"},{"kind":"typeIdentifier","text":"Self"},{"kind":"text","text":"."},{"kind":"typeIdentifier","text":"RowDecoder"},{"kind":"text","text":">]) -> "},{"kind":"typeIdentifier","text":"Self"}],"languages":["swift"],"platforms":["macOS"]}]},{"kind":"content","content":[{"anchor":"discussion","level":2,"type":"heading","text":"Discussion"},{"type":"paragraph","inlineContent":[{"type":"text","text":"For example:"}]},{"type":"codeListing","syntax":"swift","code":["struct Author: TableRecord, FetchableRecord, Decodable {"," static let books = hasMany(Book.self)","}","struct Book: TableRecord, FetchableRecord, Decodable { }","","struct AuthorInfo: FetchableRecord, Decodable {"," var author: Author"," var bookCount: Int","}","","\/\/ SELECT author.*, COUNT(DISTINCT book.id) AS bookCount","\/\/ FROM author","\/\/ LEFT JOIN book ON book.authorId = author.id","\/\/ GROUP BY author.id","let authorInfos = try Author.all()"," .annotated(with: [Author.books.count])"," .asRequest(of: AuthorInfo.self)"," .fetchAll(db)"]}]}],"schemaVersion":{"major":0,"minor":3,"patch":0},"sections":[],"variants":[{"paths":["\/documentation\/grdb\/queryinterfacerequest\/annotated(with:)"],"traits":[{"interfaceLanguage":"swift"}]}],"identifier":{"url":"doc:\/\/GRDB\/documentation\/GRDB\/QueryInterfaceRequest\/annotated(with:)","interfaceLanguage":"swift"},"abstract":[{"type":"text","text":"Appends association aggregates to the selected columns."}],"kind":"symbol","metadata":{"role":"symbol","title":"annotated(with:)","roleHeading":"Instance Method","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"annotated"},{"kind":"text","text":"("},{"kind":"externalParam","text":"with"},{"kind":"text","text":": ["},{"kind":"typeIdentifier","text":"AssociationAggregate","preciseIdentifier":"s:4GRDB20AssociationAggregateV"},{"kind":"text","text":"<"},{"kind":"typeIdentifier","text":"Self"},{"kind":"text","text":"."},{"kind":"typeIdentifier","text":"RowDecoder"},{"kind":"text","text":">]) -> "},{"kind":"typeIdentifier","text":"Self"}],"symbolKind":"method","externalID":"s:4GRDB16DerivableRequestPAAE9annotated4withxSayAA20AssociationAggregateVy10RowDecoderQzGG_tF::SYNTHESIZED::s:4GRDB21QueryInterfaceRequestV","extendedModule":"GRDB","modules":[{"name":"GRDB"}]},"hierarchy":{"paths":[["doc:\/\/GRDB\/documentation\/GRDB","doc:\/\/GRDB\/documentation\/GRDB\/QueryInterface","doc:\/\/GRDB\/documentation\/GRDB\/QueryInterfaceRequest","doc:\/\/GRDB\/documentation\/GRDB\/QueryInterfaceRequest\/DerivableRequest-Implementations"]]},"references":{"doc://GRDB/documentation/GRDB/QueryInterface":{"role":"collectionGroup","title":"Record Types and the Query Interface","abstract":[{"type":"text","text":"Record types and the query interface build SQL queries for you"}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/QueryInterface","kind":"article","type":"topic","url":"\/documentation\/grdb\/queryinterface"},"doc://GRDB/documentation/GRDB":{"role":"collection","title":"GRDB","abstract":[{"type":"text","text":"A toolkit for SQLite databases, with a focus on application development"}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB","kind":"symbol","type":"topic","url":"\/documentation\/grdb"},"doc://GRDB/documentation/GRDB/QueryInterfaceRequest":{"role":"symbol","title":"QueryInterfaceRequest","fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"QueryInterfaceRequest"}],"abstract":[{"type":"text","text":"A request that builds SQL queries with Swift."}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/QueryInterfaceRequest","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"QueryInterfaceRequest"}],"url":"\/documentation\/grdb\/queryinterfacerequest"},"doc://GRDB/documentation/GRDB/AssociationAggregate":{"role":"symbol","title":"AssociationAggregate","fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"AssociationAggregate"}],"abstract":[{"type":"text","text":"A value aggregated from a population of associated records."}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/AssociationAggregate","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"AssociationAggregate"}],"url":"\/documentation\/grdb\/associationaggregate"},"doc://GRDB/documentation/GRDB/QueryInterfaceRequest/annotated(with:)":{"role":"symbol","title":"annotated(with:)","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"annotated"},{"kind":"text","text":"("},{"kind":"externalParam","text":"with"},{"kind":"text","text":": ["},{"kind":"typeIdentifier","text":"AssociationAggregate","preciseIdentifier":"s:4GRDB20AssociationAggregateV"},{"kind":"text","text":"<"},{"kind":"typeIdentifier","text":"Self"},{"kind":"text","text":"."},{"kind":"typeIdentifier","text":"RowDecoder"},{"kind":"text","text":">]) -> "},{"kind":"typeIdentifier","text":"Self"}],"abstract":[{"type":"text","text":"Appends association aggregates to the selected columns."}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/QueryInterfaceRequest\/annotated(with:)","kind":"symbol","type":"topic","url":"\/documentation\/grdb\/queryinterfacerequest\/annotated(with:)"},"doc://GRDB/documentation/GRDB/QueryInterfaceRequest/DerivableRequest-Implementations":{"role":"collectionGroup","title":"DerivableRequest Implementations","abstract":[],"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/QueryInterfaceRequest\/DerivableRequest-Implementations","kind":"article","type":"topic","url":"\/documentation\/grdb\/queryinterfacerequest\/derivablerequest-implementations"}}}