|
25 | 25 | "name": "List PG Tables", |
26 | 26 | "type": "n8n-nodes-base.postgres", |
27 | 27 | "typeVersion": 2.6, |
28 | | - "position": [220, 0], |
29 | | - "onError": "continueRegularOutput" |
| 28 | + "position": [220, 0] |
30 | 29 | }, |
31 | 30 | { |
32 | 31 | "parameters": {"options": {}}, |
|
36 | 35 | "typeVersion": 3, |
37 | 36 | "position": [440, 0] |
38 | 37 | }, |
| 38 | + { |
| 39 | + "parameters": { |
| 40 | + "operation": "create", |
| 41 | + "documentId": {"__rl": true, "mode": "id", "value": "={{ $env.GOOGLE_SHEETS_ID }}"}, |
| 42 | + "title": "={{ $json.table_name }}" |
| 43 | + }, |
| 44 | + "id": "sheets-create", |
| 45 | + "name": "Ensure Sheet Exists", |
| 46 | + "type": "n8n-nodes-base.googleSheets", |
| 47 | + "typeVersion": 4.7, |
| 48 | + "position": [660, 0], |
| 49 | + "onError": "continueRegularOutput" |
| 50 | + }, |
39 | 51 | { |
40 | 52 | "parameters": { |
41 | 53 | "operation": "executeQuery", |
42 | | - "query": "=SELECT * FROM {{ $json.table_name }}", |
| 54 | + "query": "=SELECT * FROM {{ $('Loop Over Tables').item.json.table_name }}", |
43 | 55 | "options": {} |
44 | 56 | }, |
45 | 57 | "id": "pg-dump-table", |
46 | 58 | "name": "Dump Table", |
47 | 59 | "type": "n8n-nodes-base.postgres", |
48 | 60 | "typeVersion": 2.6, |
49 | | - "position": [660, 0], |
50 | | - "onError": "continueRegularOutput" |
| 61 | + "position": [880, 0] |
| 62 | + }, |
| 63 | + { |
| 64 | + "parameters": { |
| 65 | + "conditions": { |
| 66 | + "options": {"caseSensitive": true, "leftValue": "", "typeValidation": "strict"}, |
| 67 | + "conditions": [ |
| 68 | + { |
| 69 | + "id": "has-rows", |
| 70 | + "leftValue": "={{ $input.all().length }}", |
| 71 | + "rightValue": 0, |
| 72 | + "operator": {"type": "number", "operation": "gt"} |
| 73 | + } |
| 74 | + ], |
| 75 | + "combinator": "and" |
| 76 | + }, |
| 77 | + "options": {} |
| 78 | + }, |
| 79 | + "id": "if-has-data", |
| 80 | + "name": "Has Data?", |
| 81 | + "type": "n8n-nodes-base.if", |
| 82 | + "typeVersion": 2.3, |
| 83 | + "position": [1100, 0] |
51 | 84 | }, |
52 | 85 | { |
53 | 86 | "parameters": { |
|
59 | 92 | "name": "Clear Sheet", |
60 | 93 | "type": "n8n-nodes-base.googleSheets", |
61 | 94 | "typeVersion": 4.7, |
62 | | - "position": [880, 0], |
63 | | - "onError": "continueRegularOutput" |
| 95 | + "position": [1320, -100] |
64 | 96 | }, |
65 | 97 | { |
66 | 98 | "parameters": { |
|
77 | 109 | "name": "Write to Sheet", |
78 | 110 | "type": "n8n-nodes-base.googleSheets", |
79 | 111 | "typeVersion": 4.7, |
80 | | - "position": [1100, 0], |
81 | | - "onError": "continueRegularOutput" |
| 112 | + "position": [1540, -100] |
82 | 113 | } |
83 | 114 | ], |
84 | 115 | "connections": { |
85 | 116 | "Every 5 Minutes": {"main": [[{"node": "List PG Tables", "type": "main", "index": 0}]]}, |
86 | 117 | "List PG Tables": {"main": [[{"node": "Loop Over Tables", "type": "main", "index": 0}]]}, |
87 | | - "Loop Over Tables": {"main": [[], [{"node": "Dump Table", "type": "main", "index": 0}]]}, |
88 | | - "Dump Table": {"main": [[{"node": "Clear Sheet", "type": "main", "index": 0}]]}, |
| 118 | + "Loop Over Tables": {"main": [[], [{"node": "Ensure Sheet Exists", "type": "main", "index": 0}]]}, |
| 119 | + "Ensure Sheet Exists": {"main": [[{"node": "Dump Table", "type": "main", "index": 0}]]}, |
| 120 | + "Dump Table": {"main": [[{"node": "Has Data?", "type": "main", "index": 0}]]}, |
| 121 | + "Has Data?": {"main": [[{"node": "Clear Sheet", "type": "main", "index": 0}], [{"node": "Loop Over Tables", "type": "main", "index": 0}]]}, |
89 | 122 | "Clear Sheet": {"main": [[{"node": "Write to Sheet", "type": "main", "index": 0}]]}, |
90 | 123 | "Write to Sheet": {"main": [[{"node": "Loop Over Tables", "type": "main", "index": 0}]]} |
91 | 124 | }, |
|
0 commit comments