📌  相关文章
📜  在 firebase 数据库的子项中添加对象 - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:32.949000             🧑  作者: Mango

代码示例1
private void onStarClicked(String uid, String key) {
    Map updates = new HashMap<>();
    updates.put("posts/"+key+"/stars/"+uid, true);
    updates.put("posts/"+key+"/starCount", ServerValue.increment(1));
    updates.put("user-posts/"+uid+"/"+key+"/stars/"+uid, true);
    updates.put("user-posts/"+uid+"/"+key+"/starCount", ServerValue.increment(1));
    mDatabase.child(child).updateChildren(updates);
}