Originally created by @ghost on GitHub (Dec 13, 2016).
I have an entity Person, each person has many messages. I wish to sort my tableview based on the last message's timestamp per each Person. Essentially, accomplish something like this .
let People: ListMonitor = {
Originally created by @ghost on GitHub (Dec 13, 2016).
I have an entity Person, each person has many messages. I wish to sort my tableview based on the last message's timestamp per each Person. Essentially, accomplish something like this .
let People: ListMonitor<Person> = {
return Static.datastack.monitorSectionedList(
From<Person>(),
SectionBy(#keyPath(Person.section)),
Where("messages.@count > 0"),
OrderBy(.descending(#keyPath(Person.messages.last.timestamp))) <--------
)
}()
adam
added the question label 2025-12-29 15:24:47 +01:00
Unfortunately, Core Data doesn't support sorting lists with relationships. My suggestion is to add a messageCount attribute in the Person entity which you update whenever a message is added to a person. You can then use that attribute to sort.
@JohnEstropia commented on GitHub (Dec 14, 2016):
Unfortunately, Core Data doesn't support sorting lists with relationships. My suggestion is to add a `messageCount` attribute in the `Person` entity which you update whenever a message is added to a person. You can then use that attribute to sort.
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 @ghost on GitHub (Dec 13, 2016).
I have an entity Person, each person has many messages. I wish to sort my tableview based on the last message's timestamp per each Person. Essentially, accomplish something like this .
let People: ListMonitor = {
@JohnEstropia commented on GitHub (Dec 14, 2016):
Unfortunately, Core Data doesn't support sorting lists with relationships. My suggestion is to add a
messageCountattribute in thePersonentity which you update whenever a message is added to a person. You can then use that attribute to sort.@ghost commented on GitHub (Dec 15, 2016):
Thank you John, just making sure I wasn't missing out on a feature. I guess that should work !