我有三个域类 Author、Comment 和 Book:
class Author {
String name
static hasMany = [books: Book, comments: Comment]
}
class Book {
static belongsTo = [author: Author]
static hasMany = [comments: Comment]
}
class Comment {
static belongsTo = [book: Book, author: Author]
}
我有以下 mongoDB 查询来查找所有有给定作者评论的书籍。
Comment.findAllByAuthor(author1).collect {
it.book
}.unique().findAll {
it != null
}
我如何对这个查询使用分页,即对所有书籍进行分页?