访问子集合时,是否应该使用如下代码:
DocumentSnapshot userSnapshot = await Firestore.instance
.collection('users')
.document(userId)
.collection('shoppingLists')
.document(listName)
.get();
或者这个:
DocumentSnapshot userSnapshot = await Firestore.instance
.collection('users/$userId/shoppingLists')
.document(listName)
.get();
?
我更喜欢第一种风格。它们是否转换为相同的 I/O?
最佳答案
结果没有区别。
实际上,您甚至可以将第二个缩短为:
DocumentSnapshot userSnapshot = await Firestore.instance
.document('users/$userId/shoppingLists/$listName')
.get();
关于flutter - Cloud Firestore 子集合访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58498568/