【发布时间】:2018-10-22 15:19:41
【问题描述】:
我想查询我的锻炼收藏以获取例行程序中的最新锻炼。这意味着我使用whereEqualTo 我的routineKey 进行查询,按Started TimeStamp 以降序对其进行排序,然后限制为1,然后获取锻炼的第一个Key/Id。
但是这不起作用。 whereEqualTo 和 orderBy 单独工作,但不能组合使用。我做错了什么?
fm.getColRefWorkout().whereEqualTo("routineKey", routineKey).orderBy("startTimeStamp", Query.Direction.DESCENDING).limit(1).get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
@Override
public void onSuccess(QuerySnapshot documentSnapshots) {
workoutKey = documentSnapshots.getDocuments().get(0).getId();
//To stuff with this workoutKey
}
});
【问题讨论】:
标签: java android firebase google-cloud-firestore