You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Firebase Database中仅获取更新时间戳的指定单节点?

Firebase Realtime Database 查询问题

数据库结构

我的数据库结构如下:

path1 > uid0 > node  
      > uid1 > node
      > uid2 > node

其中node包含一个值为ServerValue.TIMESTAMP的timestamp字段。

现有可用查询

  • 获取所有timestamp > pastCutOff的节点:
FirebaseDatabase.getInstance().getReference().child("path1")
.orderByChild("timestamp").startAfter(pastCutOff).limitToLast(limit);
  • 通过已知UID获取单个指定节点:
FirebaseDatabase.getInstance().getReference().child("path1")
.child(uid);

问题与尝试

我希望仅在timestamp更新时才获取该指定单节点以节省带宽,但尝试以下查询无返回结果:

FirebaseDatabase.getInstance().getReference().child("path1")
.child(uid).orderByChild("timestamp").startAfter(pastCutOff);

另一种查询逻辑有效,但仅返回timestamp的long类型值而非完整节点:

FirebaseDatabase.getInstance().getReference().child("path1")
.child(uid).orderByValue().startAfter(pastCutOff, "timestamp");

提问

是否存在无需创建持久化valueEventListener的可行查询方式?


内容的提问来源于stack exchange,提问作者Simon Huckett

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 20:02:38