Only the following attributes seem to be returned: "id", "key", "name", "createdOn", "updatedOn" and there are no exceptions or errors present.
I know that Project has 2 Boards, so I was expecting "boardCount" to be 2.
Is what I'm doing valid? Can you call .count on a one-to-many relationship?
Many Thanks
Originally created by @damianstrain on GitHub (Aug 1, 2019).
Hi John,
I'm executing the following (where `"boards"` is a one-to-many relationship on `Project`):
```swift
try CoreStore.queryAttributes(
From<Project>(),
Select("id", "key", "name", "createdOn", "updatedOn", .count("boards", as: "boardCount"))
)
```
Only the following attributes seem to be returned: `"id", "key", "name", "createdOn", "updatedOn"` and there are no exceptions or errors present.
I know that Project has 2 Boards, so I was expecting `"boardCount"` to be 2.
Is what I'm doing valid? Can you call `.count` on a one-to-many relationship?
Many Thanks
adam
added the question label 2025-12-29 15:28:11 +01:00
@damianstrain Sorry for the long wait. The count operator here is a collection operator, which means it will count a value for a property if you use the GroupBy clause as well. Instead, can you try
@JohnEstropia commented on GitHub (Sep 22, 2019):
@damianstrain Sorry for the long wait. The count operator here is a collection operator, which means it will count a value for a property if you use the `GroupBy` clause as well. Instead, can you try
```swift
Select("id", "key", "name", "createdOn", "updatedOn", .attribute("boards.@count", as: "boardCount")))
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @damianstrain on GitHub (Aug 1, 2019).
Hi John,
I'm executing the following (where
"boards"is a one-to-many relationship onProject):Only the following attributes seem to be returned:
"id", "key", "name", "createdOn", "updatedOn"and there are no exceptions or errors present.I know that Project has 2 Boards, so I was expecting
"boardCount"to be 2.Is what I'm doing valid? Can you call
.counton a one-to-many relationship?Many Thanks
@JohnEstropia commented on GitHub (Sep 22, 2019):
@damianstrain Sorry for the long wait. The count operator here is a collection operator, which means it will count a value for a property if you use the
GroupByclause as well. Instead, can you try@damianstrain commented on GitHub (Sep 25, 2019):
Excellent! Thanks @JohnEstropia