Method: projects.databases.documents.batchWrite
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
套用批次寫入作業。
document.batchWrite 方法則會以不可分割的形式套用寫入作業,而且可能會隨機套用。這個方法規定每份文件只能寫入一次。每項寫入作業都會獨立成功或失敗。如要瞭解每次寫入的成功狀態,請參閱 BatchWriteResponse
。
如果需要一組以不可分割的形式套用的寫入作業,請改用 documents.commit
。
HTTP 要求
POST https://firestore.googleapis.com/v1/{database=projects/*/databases/*}/documents:batchWrite
這個網址使用 gRPC 轉碼語法。
路徑參數
參數 |
database |
string
必要欄位。資料庫名稱。請採用下列格式:projects/{projectId}/databases/{databaseId} 。
|
要求主體
要求主體的資料會採用以下結構:
JSON 表示法 |
{
"writes": [
{
object (Write )
}
],
"labels": {
string: string,
...
}
} |
欄位 |
writes[] |
object (Write )
要套用的寫入內容。 這個方法不會自動套用寫入作業,不保證會排序。每項寫入作業都會獨立成功或失敗。每項要求最多只能寫入同一份文件一次。
|
labels |
map (key: string, value: string)
與這項批次寫入作業相關聯的標籤。 這個物件中包含 "key": value 組合的清單,例如:{ "name": "wrench", "mass": "1.3kg", "count": "3" } .
|
回應主體
Firestore.BatchWrite
的回應。
如果成功,回應主體即會包含具有以下結構的資料:
JSON 表示法 |
{
"writeResults": [
{
object (WriteResult )
}
],
"status": [
{
object (Status )
}
]
} |
欄位 |
writeResults[] |
object (WriteResult )
套用寫入的結果。 這個 i-th 寫入結果對應要求中的第 i 次寫入。
|
status[] |
object (Status )
套用寫入的狀態。 這個 i-th 寫入狀態對應至要求中的第 i 次寫入。
|
授權範圍
需要下列其中一種 OAuth 範圍:
https://www.googleapis.com/auth/datastore
https://www.googleapis.com/auth/cloud-platform
詳情請參閱驗證總覽。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-04-12 (世界標準時間)。
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"缺少我需要的資訊"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"過於複雜/步驟過多"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"過時"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"翻譯問題"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"示例/程式碼問題"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"其他"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"容易理解"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"確實解決了我的問題"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"其他"
}]