Firestore最近添加了新的新方法FieldValue.arrayUnion(value)和FieldValue.arrayRemove(value),但我在flutter cloud_firestore包中找不到实现。有什么办法可以达到这个结果?
Firestore addUpdate:https ://firebase.google.com/docs/firestore/manage-data/add-data#update_elements_in_an_array
我有一个带有questions集合的 Cloud Firebase 数据库。每个question都有一个 map 列表options。我正在使用 Flutter 并为questionand 提供以下类option:
class Question {
final String text;
final List<Option> options; // I have tried changing this to List<dynamic> but it doesn't help
final String reference;
Question(this.text, this.options, this.reference);
Question.fromMap(Map<String, dynamic> map, {this.reference}) :
text = map['text'],
options = map['options']; // here the error happens
Question.fromSnapshot(DocumentSnapshot snapshot)
: this.fromMap(snapshot.data, reference: snapshot.documentID);
}
Run Code Online (Sandbox Code Playgroud)
和 option
class Option {
final String text;
final int votes; …Run Code Online (Sandbox Code Playgroud)