Как только пользователь нажимает кнопку «отправить», должны произойти две вещи:
- создан узел «комментария»
- создан узел «сообщения»
Однако я не могу заставить его дважды писать в firebase:
let ref = Database.database().reference()
let userProfile = UserService.currentUserProfile
let key = ref.child("post").childByAutoId().key
let feed = ["comment": commentView.text,
"username": uid,
"timestamp": [".sv":"timestamp"],
"author": [
"cid": userProfile?.uid,
"username": userProfile?.username,
"fullname": userProfile?.fullname,
"patthToImage": userProfile?.patthToImage.absoluteString]] as [String : Any]
let commentFeed = ["\(key!)" : feed]
let commentorFeed = [uid: uid]
let commentFe = ["messages": feed]
// my comment node, which is working
ref.child("posts").child(myPost).child("comment").updateChildValues(commentFeed)
ref.child("posts").child(myPost).updateChildValues(commentorFeed)
//my message node which isn't working
let ches = Database.database().reference().child("messages")
ches.setValue("hahah")
это вообще возможно?