{ "name": "Create, Update, and Read a Firestore Document", "nodes": [ { "name": "On clicking 'execute'", "type": "n8n-nodes-base.manualTrigger", "position": [ 250, 300 ], "parameters": {}, "typeVersion": 1, "id": "create-update-read-firestore-document-0" }, { "name": "Google Cloud Firestore", "type": "n8n-nodes-base.googleFirebaseCloudFirestore", "position": [ 650, 300 ], "parameters": { "columns": "id, name", "operation": "create", "projectId": "YOUR_PROJECT_ID", "collection": "YOUR_COLLECTION" }, "typeVersion": 1, "id": "create-update-read-firestore-document-1" }, { "name": "Set", "type": "n8n-nodes-base.set", "position": [ 450, 300 ], "parameters": { "values": { "number": [ { "name": "id", "value": 1 } ], "string": [ { "name": "name", "value": "n8n" } ] }, "options": {} }, "typeVersion": 1, "id": "create-update-read-firestore-document-2" }, { "name": "Set1", "type": "n8n-nodes-base.set", "position": [ 850, 300 ], "parameters": { "values": { "string": [ { "name": "name", "value": "nodemation" }, { "name": "document_id", "value": "={{$node[\"Google Cloud Firestore\"].json[\"_id\"]}}" } ] }, "options": {}, "keepOnlySet": true }, "typeVersion": 1, "id": "create-update-read-firestore-document-3" }, { "name": "Google Cloud Firestore1", "type": "n8n-nodes-base.googleFirebaseCloudFirestore", "position": [ 1050, 300 ], "parameters": { "columns": "name", "operation": "upsert", "projectId": "={{$node[\"Google Cloud Firestore\"].parameter[\"projectId\"]}}", "updateKey": "document_id", "collection": "={{$node[\"Google Cloud Firestore\"].parameter[\"collection\"]}}" }, "typeVersion": 1, "id": "create-update-read-firestore-document-4" }, { "name": "Google Cloud Firestore2", "type": "n8n-nodes-base.googleFirebaseCloudFirestore", "position": [ 1250, 300 ], "parameters": { "projectId": "={{$node[\"Google Cloud Firestore\"].parameter[\"projectId\"]}}", "collection": "={{$node[\"Google Cloud Firestore\"].parameter[\"collection\"]}}", "documentId": "={{$node[\"Set1\"].json[\"document_id\"]}}" }, "typeVersion": 1, "id": "create-update-read-firestore-document-5" }, { "id": "create-update-read-firestore-document-confirm", "name": "Confirm update", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1150, 500 ], "parameters": { "jsCode": "return $input.all().map(item => { const status = item.json.status; if (!status || typeof status !== 'object' || (status.code ?? 0) !== 0) throw new Error('Update not confirmed; inspect Firestore before retrying'); return item; });" } } ], "active": false, "settings": {}, "connections": { "Set": { "main": [ [ { "node": "Google Cloud Firestore", "type": "main", "index": 0 } ] ] }, "Set1": { "main": [ [ { "node": "Google Cloud Firestore1", "type": "main", "index": 0 } ] ] }, "On clicking 'execute'": { "main": [ [ { "node": "Set", "type": "main", "index": 0 } ] ] }, "Google Cloud Firestore": { "main": [ [ { "node": "Set1", "type": "main", "index": 0 } ] ] }, "Google Cloud Firestore1": { "main": [ [ { "node": "Confirm update", "type": "main", "index": 0 } ] ] }, "Confirm update": { "main": [ [ { "node": "Google Cloud Firestore2", "type": "main", "index": 0 } ] ] } }, "pinData": {} }