[英]firestore firebase problem: how to update the document without specifying the name of the document
您可以查詢集合 UserPrefs 並找到包含字段“weather_location”的所有文檔,然后更新所有文檔或僅更新一個。
就像是:
const querySnapshot = await firestore()
.collection('Users')
.doc(uid)
.collection('userPrefs')
.where('weather_location', '>', '')
.get();
const firstDoc = querySnapshot.docs[0];
await firestore()
.collection('Users')
.doc(uid)
.collection('userPrefs')
.doc(firstDoc.id)
.set({weather_location: location});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.