我试图将以下 flutter firebase 实时数据库代码更改为 cloud firestore,但出现此错误...
- 错误:未为类型“查询”定义方法“子项”。
- 错误:未为“查询”类型定义“推送”方法。
DatabaseReference databaseReference = FirebaseDatabase.instance.reference().child('Products');
String uploadId = databaseReference.push().key;
HashMap map = new HashMap();
map['productName'] = productName;
map['productCat'] = selectedCat;
map['startingPrice'] = int.parse(startingPrice);
map['gapPrice'] = int.parse(gapPrice);
map['imageSrc'] = url;
map['timeStamp'] = DateTime.now().toString();
databaseReference.child(uploadId).set(map);
那是因为这不是您使用 Cloud Firestore 添加文档的方式。请查看此参考以添加文档。
您的示例如下所示:
final products = Firebase.instance.collection('products');
products.add({
'productName': productName,
...
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句