我收到错误
Uncaught (in promise) FirebaseError: Invalid collection reference. Collection references must have an odd number of segments, but
Accounts/sKnjAQzJ1sQ5qRC4ki6b/RequestsReceived/m27vTB22izq6UixWP2s6 has 4.
我的密码是
var ref2 = collection(db, "Accounts/" + localStorage.getItem('Id') + "/RequestsReceived", id);
const docRef2 = await getDoc(ref2);
await deleteDoc (ref2);
我要删除的文档的URL为/Accounts/sKnjAQzJ1sQ5qRC4ki6b/RequestsReceived/m27vTB22izq6UixWP2s6
我知道如果你添加一个文档,它必须有奇数个路径,集合名称,或者集合/文档/集合。但是deleteDoc不应该有偶数个数量,因为我正在删除集合/文档或者集合/文档/集合/文档。我做错了什么?
1条答案
按热度按时间xuo3flqw1#
"Accounts/" + localStorage.getItem('Id') + "/RequestsReceived", id
此路径指向“RequestsReceived”子集合中的文档。因此应使用
doc()
创建DocumentReference。此外,只要您有引用,就不需要在删除之前获取文档: