我把我的Firestore簡單資料庫設定為一個欄位,并且我根據檔案檢查了GET請求:
/projects/YOUR_PROJECT_ID/databases/(default)/documents/cities/LA
但是我無法理解補丁請求檔案。在這個補丁請求模式中。 https://firestore.googleapis.com/v1/projects/{project_id}/databases/{database_id}/documents/{document_path}?updateMask.fieldPaths=KEYVALUE.VALUE/a>
我很困惑,我應該如何使用這一點來進行修補請求?我怎樣才能獲得檔案路徑? 懇請指導。 謝謝
uj5u.com熱心網友回復:
你需要按照檔案中指定的格式傳遞更新的資料:
fetch("https://firestore. googleapis.com/v1/projects/[PROJECT_ID]/databases/(default)/documents/[COLLECTION]/[DOC_NAME]?currentDocument.exists=true& updateMask.fieldPaths=name& alt=json", {
headers: {
authorization: "承載[ACCESS_TOKEN]"。
"內容型別"。"application/json"。
},
body: JSON.stringify({ fields: { name : { stringValue : "用戶名"}},
method: "PATCH"。
});
請注意完整的請求URL。它包含一個查詢引數updateMask.fieldPaths=name。如果缺少這個引數,完整的檔案將被新的資料所取代。fields屬性是一個地圖,你必須指定欄位型別,如上所示。你可以找到更多關于價值型別的資訊這里
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/309944.html
標籤:
下一篇:將輸入的5位數轉換為文字
