MongoDB schema design - finding the last X comments across all blog posts filtered by user

会有一股神秘感。 提交于 2019-12-08 19:10:35
  1. Either put @Indexes(@Index("comments.commenter")) on the Post class, or @Indexed on the commenter field of the Comment class (Morphia's Datastore.ensureIndexes() will recurse in the classes and correctly create the comments.commenter index on the Post collection)

  2. I think ds.find(Post.class, "comments.commenter in", users) would work, ds being a Datastore and users your List<SiteUser> (I don't use @Reference though, so I can't confirm; you might have to first extract the list of their Keys).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!