【发布时间】:2020-08-09 04:32:00
【问题描述】:
所以我需要返回一个主题集合,每个主题都有一个“mostRecentThree”属性,其中包含 3 个最新帖子
我有 2 个收藏
主题
{name:'food', foo:bar}
发帖
{ topic:'food', created: someDate }
返回结果应该是设置了recentThree属性的集合
{name:food, recentThree: [postId1, postId2, postId3], foo:bar}
最有效的方法是什么?
【问题讨论】:
-
到目前为止你尝试过哪些低效的方法?
-
我在将帖子插入帖子集合时更新了 newRecentThree 属性。不幸的是,由于遗留支持,我无法直接在数据库中设置实际的 recentThree 属性(这与最流行的最近 3 略有不同)所以我在查询返回后将 newRecentThree 的结果重新映射到 recentThree。