gpt4 book ai didi

ios - Firestore 读取旧数据

转载 作者:行者123 更新时间:2023-11-28 23:56:28 26 4
gpt4 key购买 nike

我已经删除了我的“卡片”收藏中的所有文档。但我的旧数据不断出现!我最近更新了我的 Firebase Pod。

这是我的阅读数据代码:

CARDS_REF.addSnapshotListener({ (snapshot, error) in
if let error = error {
debugPrint("ERROR WHILE FETCHING CARDS: \(error.localizedDescription)")
return
}

var newCards = [Card]()
guard let snaps = snapshot else { return }
for snap in snaps.documents {
let newCard = Card(key: snap.documentID, dictionary: snap.data() as [String: AnyObject])

let timeStamp = newCard.expirationDate
let expirationDate: Date = timeStamp!.dateValue()
let currentDate = Date()

if currentDate < expirationDate {
newCards.append(newCard)
}
}

self.cards = newCards
self.mainVC?.cardsLoaded()
})

这是CARDS_REF:

let firestoreRef = Firestore.firestore() // <-- Declared outside of class
fileprivate var _CARDS_REF = firestoreRef.collection("cards") // <-- Declared inside DataService class

var CARDS_REF: CollectionReference { // <-- Declared inside DataService class
return _CARDS_REF
}

有什么想法吗?谢谢!

最佳答案

是的,Firebase 正在为您缓存数据。要禁用此功能,请执行以下操作:

let settings = FirestoreSettings()
settings.isPersistenceEnabled = false
db.settings = settings // db is your firebase database reference.

关于ios - Firestore 读取旧数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51119093/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com