我想在我的列表中添加一个新项目,我使用firebase而不使用用户(电子邮件,密码)
我想添加这样的新项目: -
list
-vdjs43ndjufd87
"name" : Jak
"university" : Harvard
list
-vdjs43ndjufd87
"name" : Jak
"university" : Harvard
"age" : 23
此代码与我无关: -
let key = ref.child("posts").childByAutoId().key
let post = ["uid": userID,
"author": username,
"title": title,
"body": body]
let childUpdates = ["/posts/\(key)": post,
"/user-posts/\(userID)/\(key)/": post]
ref.updateChildValues(childUpdates)`h
答案 0 :(得分:0)
您需要做的就是:
let post = ["uid": userID,
"author": username,
"title": title,
"body": body]
ref.child("posts").childByAutoId().setValue(post)