CoreStore icon indicating copy to clipboard operation
CoreStore copied to clipboard

I try to sort datetime by descending order

Open oddukgi opened this issue 3 years ago • 2 comments

I make variable

     let fetchingItems =  [ { (newDate) -> [DataType] in
        
     return try! UserDataManager.dataStack.fetchAll(From<DataType>(UserDataManager.veggieConfiguration)
                    .where(format: "%K BEGINSWITH[c] %@",#keyPath(DataType.createdDate),newDate).orderBy(.descending(\.createdDate)))
        
      },
      {   (newDate) -> [DataType] in
                
           return try! UserDataManager.dataStack.fetchAll(From<DataType>(UserDataManager.fruitsConfiguration)
                            .where(format: "%K BEGINSWITH[c] %@",#keyPath(DataType.createdDate),newDate).orderBy(.descending(\.createdDate)))
        
        } ]

DateTime is string type. I create datetime like "yyyy.MM.dd h:mm:ss a" I want to show recent data is first. When time changed 11pm, ordering didn't change.

oddukgi avatar Aug 25 '20 04:08 oddukgi

I’m not sure if understand your issue, but fetchAll() returns an array, and the ordering would be fixed during fetch time.

If you want a list that changes ordering dynamically, use ListPublishers or ListMonitors

JohnEstropia avatar Aug 25 '20 04:08 JohnEstropia

Ok. I will check ordering works fine at night time. If didn't work, follow your advice. 🦊

oddukgi avatar Aug 25 '20 05:08 oddukgi