通过排序从解析数据库中检索最新的
Retrieve the most recent from the parse database by sorting
我是 Parse 新手。我在解析中有一个 Class,它具有以下字段:objectId entryTime exitTime。所以我有很多记录具有相同的 objectID 和不同的 entryTime 和 exitTime。我希望能够使用 ObjectId 和最近的 entryTimeStamp 从这个 class 中检索最近的记录。我怎样才能做到这一点?
所以我的Class中的记录示例如下
ObjectId entryTime exitTime
1. O4ZnG0cr6C Sat Feb 21 17:28:43 EST 2015 Sat Feb 21 17:28:43 EST 2015
2. O4ZnG0cr6C Sat Feb 21 17:28:40 EST 2015 Sat Feb 21 17:29:43 EST 2015
如果当前时间是 2 月 21 日星期六 17:28:44 EST 2015 我想从此列表中检索最上面的记录。
谢谢你。
您可以使用 ascending()
或 descending()
。
例如,如果您的查询名为 query
,query.ascending("parameter you want to sort")
应该为您排序结果。
如果不行你可以试试query.orderByAscending("...")
请注意,这些方法仅接受 strings/string 个变量。
我是 Parse 新手。我在解析中有一个 Class,它具有以下字段:objectId entryTime exitTime。所以我有很多记录具有相同的 objectID 和不同的 entryTime 和 exitTime。我希望能够使用 ObjectId 和最近的 entryTimeStamp 从这个 class 中检索最近的记录。我怎样才能做到这一点? 所以我的Class中的记录示例如下
ObjectId entryTime exitTime
1. O4ZnG0cr6C Sat Feb 21 17:28:43 EST 2015 Sat Feb 21 17:28:43 EST 2015
2. O4ZnG0cr6C Sat Feb 21 17:28:40 EST 2015 Sat Feb 21 17:29:43 EST 2015
如果当前时间是 2 月 21 日星期六 17:28:44 EST 2015 我想从此列表中检索最上面的记录。 谢谢你。
您可以使用 ascending()
或 descending()
。
例如,如果您的查询名为 query
,query.ascending("parameter you want to sort")
应该为您排序结果。
如果不行你可以试试query.orderByAscending("...")
请注意,这些方法仅接受 strings/string 个变量。