我已经可以使用以下代码将数据上传到我的Firestore中。
class AddressUpdate {
final String phonenumber;
final String address1;
final String address2;
final String city;
final String state;
final String zipCode;
final String uid;
AddressUpdate(
{
this.phonenumber,
this.address1,
this.address2,
this.city,
this.state,
this.zipCode,
this.uid});
}
// add address to firestore
Future<void> updateAddress(
address1, address2, phonenumber, city, state, zipCode) async {
return await signUpCollection.document(uid).collection('address').add({
'address1': address1,
'address2': address2,
'phonenumber': phonenumber,
'city': city,
'state': state,
'zipcode': zipCode,
});
}
Future updateAddress(address1, address2, phonenumber,
city, state, zipCode) async {
notifyListeners();
FirebaseUser user = await _auth.currentUser();
await Database(uid: user.uid).updateAddress(address1, address2,
phonenumber, city, state, zipCode);
}
我如何从地址集合中获取全部数据,以便由于add方法具有一个uid,所以我能够分别更新每个数据。