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

Flutter中如何从Firebase实时数据库筛选指定条件的用户ID

获取符合条件的用户ID

需求说明

  • 从collection集合中筛选出所有包含AC投诉且状态为**等待中(waiting)**的用户ID
  • 注意:并非每个用户ID下都存在AC投诉相关内容

查询实现(以Firebase实时数据库为例)

const db = firebase.database();
const collectionRef = db.ref('collection');

collectionRef.once('value')
  .then(snapshot => {
    const targetUserIds = [];
    snapshot.forEach(userNode => {
      const userContent = userNode.val();
      // 校验是否存在AC投诉且状态为waiting
      if (userContent['AC complaint'] && userContent['AC complaint'].status === 'waiting') {
        targetUserIds.push(userNode.key);
      }
    });
    // 输出符合条件的用户ID
    targetUserIds.forEach(id => console.log(id));
  })
  .catch(err => {
    console.error('查询失败:', err);
  });

输出示例

A2QMPPbXUxVjeyCBK6AVVmrTcw12
BQ8BqdOrbKZuJnSOTAEoCtfgxjl1

内容的提问来源于stack exchange,提问作者Dhanesh Sawant

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.18 18:12:36