[英]How to create a custom document in collection - Firestore with Flutter
I sign in my user through google, after successfully login.成功登录后,我通过谷歌登录我的用户。 I wants to create document for each user inside user_details collection and the document name should be google id .我想为user_details集合中的每个用户创建文档,文档名称应该是google id 。 But its auto generating document name.但它的自动生成文档名称。
Is there any way to create custom document in Firestore?有没有办法在 Firestore 中创建自定义文档?
Thanks in Advance提前致谢
// Store data in Firestore
storeData(User user) async {
DocumentReference documentRef =
Firestore.instance.collection("user_details").document(user.id);
Firestore.instance.runTransaction((transaction) async {
await transaction.set(documentRef, user.toJson());
print("instance created");
_login.add(Result(Status.SUCCESS, "Login successful.", user));
});
}
试试这个await documentRef.setData(user.toJson());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.