0
我使用Firebase數據庫,我有一張卡片列表,如果它們被刪除,我需要監視一些卡片。我試圖用ref.observe (.childRemoved)
來做到這一點,但這不適合我的情況,因爲持卡人可以刪除一些數據,然後這個模塊會觸發多次,我需要觀察整個卡是否被刪除。我怎樣才能做到這一點?如何觀察從Firebase數據庫中刪除模型?
我參考
let ref = FIRDatabase.database().reference().child(MainGateways.cards.rawValue).child(card.id)
我的卡結構
"cards": {
"-Khv9rUVwErNHBzXcruO": {
"additionalInfo": {
"note": ""
},
"dateProperties": {
"day": "Flex",
"isFlexDate": true,
"isFlexTime": true,
"iso8601": "",
"time": ""
},
"interestedUsers": {
"NfM26A2YcPUFz8rfYa23Kr3mjCO2": {
"isApproved": false,
"isNew": true,
"isoDate": "2017-04-17T13:08:41+04:00",
"userID": "NfM26A2YcPUFz8rfYa23Kr3mjCO2",
"userItchableName": "Alexsander K."
}
},
"isNewPendingRequest": true,
"isPrivateStatus": false,
"isTest": false,
"ownerID": "1Cix149ThIOG1ULPVjyy0LyTxbe2",
"peopleProperties": {
"availableSeats": 1,
"numberOfPeople": 1,
"numberOfPeopleDescription": "1 person"
},
"title": "Genius Lounge and Sake Bar",
"userName": "Tim C.",
"version": 1
},
我也試圖使這種聯繫,但隨後如果有卡被從名單中剔除此塊工作。
guard let ref = FIRDatabase.database().reference().child(MainGateways.cards.rawValue).child(card.id).parent else { return }