dpg2905 2019-03-28 04:53
浏览 48
已采纳

如何查找日期晚于所有记录?

I have a firebase db like the one below:

enter image description here

and I'd like to select all events that come after a certain date. I've attempted to do this with the following code:

events := []data.EventData{}

if err := ref.Child("date").OrderByValue().StartAt(time.Now()).Get(c, events); err != nil {
    fmt.Println("Error selecing upcoming events")
    fmt.Println("Error:", err)
    response.Message = "Problem getting upcoming events"
    c.JSON(http.StatusInternalServerError, response)
    return
}

But it keeps throwing the error:

Index not defined, add ".indexOn": ".value", for path "/Event/date", to the rules

What does this mean and how do I go about selecting the records that I need? Am I on the right track and just need to resolve this error or should I be taking a different approach?

  • 写回答

1条回答 默认 最新

  • dongqian5384 2019-03-28 05:01
    关注

    Firebase is asking you add an index to date to improve query performance. AFAIK, you are able to get data you need without adding any index. But it will be quite slow as your event data grow. check the link for reference: https://firebase.google.com/docs/database/security/indexing-data

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥66 比特币地址如何生成taproot地址
  • ¥20 数学建模数学建模需要
  • ¥15 关于#lua#的问题,请各位专家解答!
  • ¥15 什么设备可以研究OFDM的60GHz毫米波信道模型
  • ¥15 不知道是该怎么引用多个函数片段
  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决