Coredata中的嵌套数据过滤器?

发布于 2025-02-07 01:57:17 字数 500 浏览 0 评论 0原文

是否可以过滤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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文