【发布时间】:2020-05-01 07:58:07
【问题描述】:
所以我想看看是否有办法将特定文档从最新到最旧排序 有没有办法从firestore做到这一点?还是我必须编码?
这是关于我如何获取特定文档 ID 的代码,我只是使用 UUID().string 为我生成了一个
func quoteMeVariables(){
let quotemodel = quoteME()
quotemodel.quoteMEid = UUID().uuidString
quotemodel.author = authorTextfield.text
quotemodel.QuoteText = quoteMeTextfield.text
quotemodel.saveQuoteMetoFirebase(quotemodel) //
hud.textLabel.text = "Your Quote Has Been Sent Successfully!"
hud.show(in: self.view)
hud.indicatorView = JGProgressHUDSuccessIndicatorView()
hud.dismiss(afterDelay: 3.0)
DispatchQueue.main.asyncAfter(deadline: .now() + 3.0){
self.dismiss(animated: true, completion: nil)
}
}
【问题讨论】:
-
您需要添加时间戳才能根据该时间戳进行排序
-
有许多解决方案,但您在问题中显示的不是数组。话虽如此,如果您只是在每个文档中添加一个时间戳字段,它们就可以轻松排序。
标签: swift firebase google-cloud-firestore