1
我有三個域類作者,註釋和圖書:如何在Grails中對複雜的mongoDB查詢進行分頁?
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
}
我該如何對這個查詢使用分頁,即對所有書籍進行分頁?