【问题标题】:Is there a way to use the orderBy() function from firestore using getDocs?有没有办法通过 getDocs 使用 firestore 中的 orderBy() 函数?
【发布时间】:2022-01-02 04:35:40
【问题描述】:

我目前正在尝试这个(实际上并没有订购任何东西)

let articlesSnapshot = await getDocs(articlesRef, orderBy('timestamp'));

在文档中,他们仅使用查询而不是 getDocs 来显示此用例... 有没有办法解决这个问题?

【问题讨论】:

    标签: javascript firebase google-cloud-firestore


    【解决方案1】:

    诀窍是这样create a query

    let articlesSnapshot = await getDocs(query(articlesRef, orderBy('timestamp')));
    

    【讨论】:

    • 感谢您的回答。正是我想要的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-30
    • 2019-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多