Firebase Flatter firestore使用特定键写入数据
我想上传一些数据到Firestore,但我不知道如何设置数据的特定密钥。我发现以前在这里讨论过这一点,但对于旧的Firebase数据库,现在的语法不同了Firebase Flatter firestore使用特定键写入数据,firebase,flutter,firebase-realtime-database,google-cloud-firestore,Firebase,Flutter,Firebase Realtime Database,Google Cloud Firestore,我想上传一些数据到Firestore,但我不知道如何设置数据的特定密钥。我发现以前在这里讨论过这一点,但对于旧的Firebase数据库,现在的语法不同了 Future<void> writeProfileData(Map<String, dynamic> profileData) async { await _databaseReference .collection('profile') .add(profileData) .catchError
Future<void> writeProfileData(Map<String, dynamic> profileData) async {
await _databaseReference
.collection('profile')
.add(profileData)
.catchError((error) => print(error.toString()));
}
Future writeProfileData(映射配置文件数据)异步{
等待数据库参考
.collection('配置文件')
.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);
}
Future writeProfileData(映射配置文件数据)异步{
var ref=Firestore.instance.document('profile/profileData');
参考setData(外形数据);
}