我試圖做一個很簡單的事情,是這樣的:是否可以從對象中更改Firebase路徑?
root: {
objects: {
id_subobj1: { // these are two objects doing current events.
name: "subName1",
description: "it's nice"
},
id_subobj2: {
name: "subName2",
description: "it's cool"
}
},
history: {
// once they are done, I'd like to store them in this branch as an exact copy as they were in the "Objects" branch.
id_subobj: {
name: "name",
description: "it was nice"
}
}
}
我想實現的是讓我的對象,像複製並粘貼到歷史的分支。
我試圖這樣做,但我沒有這樣做的成功。
任何想法?
如果您已經嘗試過這種方法,請分享[重現您卡住的最小代碼](http://stackoverflow.com/help/mcve)。 –
簡要答案是。通過.value觀察對象節點。將它們追加到數組中。遍歷數組並將setValue遍歷到每個歷史節點。使用Firebase的關鍵是完成[入門](https://firebase.google.com/docs/database/ios/start)指南,因爲它們完全涵蓋了如何完成此任務。投票結束,因爲它太模糊。 – Jay
感謝您的回答,我已經達到了這個目標,忘了我發佈了這個。我所做的是從'objects'分支獲取'snapshot.val()'並更新'history'分支,並且我得到了每個子對象'objects'都包含的關鍵字 - 對於我。謝謝你的時間。 – RaulGM