我有这个 Backendless 表:Posts
和Comments
Posts 有一列comments
与 Comments 表具有一对多的关系。
我试图获得comments
latestOrder 的第一行为。
目前,我有这个查询:
let query = BackendlessDataQuery()
let queryOptions = QueryOptions()
queryOptions.pageSize = size
queryOptions.related = ["comments", "comments.user", "user", "media"]
query.queryOptions = queryOptions
// Used PostObject since it is already mapped using `mapTableToClass`
backendlessInstance.persistenceService.of(PostObject.ofClass()).find(
query,
response: { backendlessPostsList in
let backendlessPostsListOfOffset = backendlessPostsList.getPage(offset)
guard let postObjects = backendlessPostsListOfOffset.getCurrentPage() as? [PostObject] else {
reject(BackendlessError.InvalidTypeForObject(name: "Post"))
return
}
return postObjects
},
error: { fault in
// TODO Find a way to convert a Fault to ErrorType
print("Server reported an error (1): \(fault)")
}
)
我目前正在对视图模型中的 Post.comments 进行排序正在反转它。Post.comments.reverse()
.
有没有办法明确地对comments
Backendless 级别进行排序?