firebase - 如何通过 uid 从实例 user_type 获取数据(Firebase 颤振)
解决方案
为您的用户集合创建一个变量
final CollectionReference _usersCollection =
FirebaseFirestore.instance.collection("users");
根据 userId 值查询用户文档快照
final QuerySnapshot<Object?> usersQuery = await _usersCollection.where("uid",isEqualTo: userId).limit(1).get();
您可以从文档快照中获取地图数据
if(usersQuery.length>0) {
final Map<String, dynamic> userData =
usersQuery.docs[0].data() as Map<String, dynamic>;
return userData['userType']; // you can use the data as you wish here am returning it
}
// else do something when the data isn't available
推荐阅读
- angular - Angular10为一条路线动态/条件导入模块
- opencv - OpenCV Rodrigues 旋转向量不是右手的
- google-calendar-api - 我的用户已将身份验证范围的所有权限授予谷歌日历,但 API 返回 403 错误?
- javascript - Flasgger / Swagger - apidocs 适用于 localhost 但不适用于 Openshift(您需要启用 JavaScript 才能运行此应用程序)
- java - Jaeger 如何根据 ID 跟踪特定消息
- lua - 单击时如何获得一次信号
- javascript - 解构数组中可能的空值
- excel - Power Query 在保留原始列内容的同时提取列文本?
- java - 试图编写一个 quarkus camel awssqs 消费者
- flutter - 模拟器不再加载,我该怎么办?