Currently I add a new post to my Firebase array by observing for the array first, appending my new post, and then updating the ref:
REF_USER.child(UID).observeSingleEventOfType(.Value, withBlock: { snapshot in
if !snapshot.exists() {return}
if let dict = snapshot.value as? Dictionary<String, AnyObject>,
let posts = dict["posts" as? [String] {
posts.append(newPost)
REF_USER.child(UID + "/posts").setValue(posts)
}
}
Is there a way to skip the step of observing, and straight away update posts in an array? Hypothetically, something like:
REF_USER.child(UID + "/posts").addToArray(newPost)