ฉันยังใหม่กับ firebase นี่คือฐานข้อมูลของฉัน ฉันได้ดึงข้อมูลจาก TopCategories และแสดงไว้บน UI ได้สำเร็จ ตอนนี้เมื่อผู้ใช้คลิกที่หมวดหมู่ ฉันต้องการส่งข้อความค้นหาไปยัง firebase และต้องการดึงข้อมูลบันทึกทั้งหมดตาม CategoryId ข้อเสนอแนะและความช่วยเหลือของคุณจะเป็นสิ่งจำเป็น ขอบคุณล่วงหน้า !
จะดึงข้อมูลบันทึกทั้งหมดตามแนวคิดคีย์ต่างประเทศของ MYSQL ใน firebase ได้อย่างไร
comment
การสะกด categoryID ใน TopCategories และ ProductDetail ไม่ตรงกัน
- person AndroidGeek   schedule 26.10.2016
คำตอบ (1)
ฉันหายไป
Query allproductQuery = ref.orderByChild(ProductDetail.categoryId)
.equalTo(categoryId);
รหัสสุดท้าย
Firebase ref=new Firebase(Constant.FIREBASE_URL+"/ProductDetail");
Query allproductQuery=ref.orderByChild(ProductDetail.categoryId).equalTo(categoryId);
allproductQuery.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Log.i("success product count",dataSnapshot.getChildrenCount()+"");
tempProduct=new ProductDetail();
for(DataSnapshot dataSnapshot1 : dataSnapshot.getChildren()){
tempProduct=dataSnapshot1.getValue(ProductDetail.class);
mProductList.add(tempProduct);
}
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
อาจเป็นประโยชน์สำหรับใครบางคน
person
iqbal lone
schedule
19.06.2016