Coredata中的嵌套数据过滤器?
是否可以过滤Coredata中的数据? 使用谓词我已经按名称进行排序。 但是我需要按日期进行排序,例如,每月选择付款。
有两个实体:
CategoriesEntity
name:String
TransactionsEntity:
sum: Double
date: Date
note: String
当过滤时,我会按类别获得列表,
let predicate = filterKey.isEmpty ? nil : NSPredicate(format: "name CONTAINS[cd] %@", filterKey)
fetchRequest = FetchRequest<T>(entity: T.entity(), sortDescriptors: [], predicate: predicate)
但是如果该列表是实体类别中的嵌套实体,我该如何按日期进行交易?
UPD:类别和交易是一对多连接的
Is it possible to filter the data in CoreData?
Using predicate I have sorted by name.
But I need to sort by date, make a selection of payments per month, for example.
There are two entities:
CategoriesEntity
name:String
TransactionsEntity:
sum: Double
date: Date
note: String
when filtering i get a list by category
let predicate = filterKey.isEmpty ? nil : NSPredicate(format: "name CONTAINS[cd] %@", filterKey)
fetchRequest = FetchRequest<T>(entity: T.entity(), sortDescriptors: [], predicate: predicate)
but how can I take transactions by date from the request if it is a nested entity in the entity category?
upd: categories and transactions are connected One-to-many
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论