![](/img/trans.png)
[英]Firestore how to fetch specific data with specific user id in Flutter
[英]Flutter firestore write data with specific key
我想将一些数据上传到 Firestore,但我不知道如何为数据设置特定的键。 我发现之前在这里讨论过这个问题,但是使用旧的 Firebase 数据库,现在语法不同了。
Future<void> writeProfileData(Map<String, dynamic> profileData) async {
await _databaseReference
.collection('profile')
.add(profileData)
.catchError((error) => print(error.toString()));
}
现在我的数据密钥是自动生成的,我想要像.key(profileData['uid'])
非常感谢。
您可以使用以下语法:
Future<void> writeProfileData(Map<String, dynamic> profileData) async {
var ref = Firestore.instance.document('profile/profileData');
ref.setData(profileData);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.