具有指定子键的firebase orderByChild()不起作用

时间:2018-10-26 04:07:10

标签: android firebase firebase-realtime-database

我正在尝试获取具有当前用户uid的数据并按时间排序,但是以某种方式我的查询也带来了具有其他uid的数据

这是我的查询

 FirebaseDatabase.getInstance().getReference().child("posts").orderByChild("uid_timestamp/"+uid).limitToLast(12)
            .addListenerForSingleValueEvent(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    items.clear();
                    for (DataSnapshot item : dataSnapshot.getChildren()) {
                        items.add(item.getValue(PostModel.class));
                        Log.d("checking","writerUid "+item.getValue(PostModel.class).writerUid);
                    }

这是我的数据库

enter image description here

因此writerUid与时间在uid_timestamp中。我使用了错误的儿童钥匙吗?我需要你的帮助!

0 个答案:

没有答案
相关问题