From 047a95f2c98e786c6642e08b41fff3f8af28d494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 2 Oct 2018 23:01:23 +0200 Subject: [PATCH] Improve sample code --- Documentation/AssociationsBasics.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/AssociationsBasics.md b/Documentation/AssociationsBasics.md index b4e556db9..0002a5c1a 100644 --- a/Documentation/AssociationsBasics.md +++ b/Documentation/AssociationsBasics.md @@ -1514,7 +1514,7 @@ You can compute aggregates on subsets of associated records with the `filter` me ```swift struct AuthorInfo: Decodable, FetchableRecord { var author: Author - var bookCount: Int + var novelCount: Int } // SELECT author.*, @@ -1523,7 +1523,7 @@ struct AuthorInfo: Decodable, FetchableRecord { // LEFT JOIN book ON book.authorId = author.id AND book.kind = 'novel' // GROUP BY author.id let novels = Author.books.filter(Column("kind") == "novel") -let request = Author.annotated(with: novels.count()) +let request = Author.annotated(with: novels.count(aliased: "novelCount")) let authorInfos: [AuthorInfo] = try AuthorInfo.fetchAll(db, request) ```