{"id":35698,"date":"2026-01-09T15:20:32","date_gmt":"2026-01-09T08:20:32","guid":{"rendered":"https:\/\/dps.media\/toi-uu-hoa-dong-bo-du-lieu-voi-node-supabase-upsert-cho-n8n-giai-phap-toan-dien\/"},"modified":"2026-01-09T15:20:32","modified_gmt":"2026-01-09T08:20:32","slug":"%e4%bc%98%e5%8c%96%e5%90%8c%e6%ad%a5%e6%95%b0%e6%8d%ae%e4%b8%8e%e8%8a%82%e7%82%b9-supabase-upsert%e7%94%a8%e4%ba%8en8n-%e5%85%a8%e9%9d%a2%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88","status":"publish","type":"post","link":"https:\/\/dps.media\/zh\/%e4%bc%98%e5%8c%96%e5%90%8c%e6%ad%a5%e6%95%b0%e6%8d%ae%e4%b8%8e%e8%8a%82%e7%82%b9-supabase-upsert%e7%94%a8%e4%ba%8en8n-%e5%85%a8%e9%9d%a2%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88\/","title":{"rendered":"\u4f7f\u7528Node Supabase Upsert\u4e3an8n\u540c\u6b65\u4f18\u5316\u6570\u636e\uff1a\u5168\u9762\u89e3\u51b3\u65b9\u6848"},"content":{"rendered":"<p>\u5728\u81ea\u52a8\u5316\u548c\u7cfb\u7edf\u96c6\u6210 (system integration) \u65f6\u4ee3\uff0c\u5c06\u4e0d\u540c\u5e73\u53f0\u4e4b\u95f4\u7684\u6570\u636e\u540c\u6b65\u662f\u5e38\u89c1\u4f46\u5145\u6ee1\u6311\u6218\u7684\u4efb\u52a1\u4e4b\u4e00\u3002\u60a8\u6709\u4e00\u4e2a\u6765\u81ea CRM \u7684\u5ba2\u6237\u5217\u8868\u3001\u4e00\u4e2a\u6765\u81ea Excel \u6587\u4ef6\u7684\u4ea7\u54c1\u8868\uff0c\u6216\u6765\u81ea IoT \u7684\u4f20\u611f\u5668\u6570\u636e\uff0c\u60a8\u9700\u8981\u5c06\u5b83\u4eec\u5bfc\u5165\u81ea\u5df1\u7684 Supabase \u6570\u636e\u5e93\u3002.<\/p>\n<p>\u95ee\u9898\u51fa\u73b0\u5728\u60a8\u5fc5\u987b\u56de\u7b54\u8fd9\u4e2a\u95ee\u9898\u65f6\uff1a\u201c\u8fd9\u4e2a\u6570\u636e\u5df2\u7ecf\u5b58\u5728\u4e86\u5417\uff1f\u201d\u3002\u5982\u679c\u6ca1\u6709\uff0c\u60a8\u9700\u8981 <strong>\u65b0\u589e (Insert)<\/strong>. \u3002\u5982\u679c\u5df2\u7ecf\u5b58\u5728\uff0c\u60a8\u9700\u8981 <strong>\u66f4\u65b0 (Update)<\/strong>. \u3002\u8fd9\u4e2a\u8fc7\u7a0b\u88ab\u79f0\u4e3a <strong>\u66f4\u65b0\/\u63d2\u5165<\/strong>.<\/p>\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u6df1\u5165\u63a2\u8ba8\u5982\u4f55\u4f7f\u7528 n8n \u4e2d\u7684\u81ea\u5b9a\u4e49\u8282\u70b9 <strong>Supabase Upsert<\/strong> \u6765\u5f7b\u5e95\u3001\u9ad8\u6548\u4e14\u6027\u80fd\u6700\u4f18\u5730\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/dps.media\/wp-content\/uploads\/mcp\/2026\/01\/supabase_upsert_logic_1767946305817.jpg\" alt=\"Supabase Upsert\u903b\u8f91\" title=\"\"><\/p>\n<h2>\u624b\u52a8\u6570\u636e\u540c\u6b65\u7684\u75db\u82e6<\/h2>\n<p>\u5728\u8fdb\u5165\u89e3\u51b3\u65b9\u6848\u4e4b\u524d\uff0c\u8ba9\u6211\u4eec\u56de\u987e\u4e00\u4e0b\u6211\u4eec\u5728 n8n \u4e2d\u4f20\u7edf\u4e0a\u5904\u7406\u8fd9\u4e2a\u95ee\u9898\u7684\u5e38\u89c1\u65b9\u5f0f\u3002\u901a\u5e38\uff0c\u60a8\u5fc5\u987b\u6784\u5efa\u4e00\u4e2a\u76f8\u5f53\u7b28\u91cd\u7684 workflow\uff1a<\/p>\n<ol>\n<li><strong>\u83b7\u53d6\u6e90\u6570\u636e<\/strong>: \u4ece Google Sheets\u3001Webhook \u6216 API \u8bfb\u53d6\u3002.<\/li>\n<li><strong>\u5728 Supabase \u4e2d\u67e5\u8be2<\/strong>: \u4f7f\u7528\u4e00\u4e2a Supabase \u8282\u70b9\u8fdb\u884c \u201cSelect\u201d \u4ee5\u67e5\u770b\u76f8\u5e94 ID \u7684\u8bb0\u5f55\u662f\u5426\u5b58\u5728\u3002.<\/li>\n<li><strong>\u68c0\u67e5\u6761\u4ef6 (IF \u8282\u70b9)<\/strong>:\n<ul>\n<li>\u5982\u679c\u8fd4\u56de\u6570\u636e\u4e3a\u7a7a (True) -&gt; \u8df3\u8f6c\u5230\u5206\u652f <strong>\u63d2\u5165<\/strong>.<\/li>\n<li>\u5982\u679c\u6570\u636e\u6709\u8fd4\u56de (False) -&gt; \u8df3\u8f6c\u5230\u5206\u652f <strong>\u66f4\u65b0<\/strong>.<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u6267\u884c<\/strong>: \u8fd0\u884c\u76f8\u5e94\u7684 Insert \u6216 Update \u8282\u70b9\u3002.<\/li>\n<\/ol>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u6709\u8bb8\u591a\u81f4\u547d\u7f3a\u70b9\uff1a<\/p>\n<ul>\n<li><strong>\u8d44\u6e90\u6d88\u8017\u9ad8<\/strong>: \u60a8\u5fc5\u987b\u4e3a\u6bcf\u884c\u6570\u636e\u6267\u884c\u81f3\u5c11 2 \u4e2a\u8bf7\u6c42 (Select + Insert\/Update)\u3002.<\/li>\n<li><strong>\u901f\u5ea6\u6162<\/strong>: \u5904\u7406\u6570\u5343\u884c\u65f6\uff0c\u7f51\u7edc\u5ef6\u8fdf (latency) \u4f1a\u4f7f\u5de5\u4f5c\u6d41\u8fd0\u884c\u5f88\u957f\u65f6\u95f4\u3002.<\/li>\n<li><strong>\u96be\u4ee5\u7ef4\u62a4<\/strong>: \u5de5\u4f5c\u6d41\u53d8\u5f97\u590d\u6742\uff0c\u8fde\u63a5\u7ebf\u4ea4\u7ec7\uff0c\u5bb9\u6613\u51fa\u73b0\u903b\u8f91\u9519\u8bef\u3002.<\/li>\n<li><strong>\u7ade\u6001\u6761\u4ef6\u98ce\u9669<\/strong>: \u5728\u591a\u7ebf\u7a0b\u73af\u5883\u4e2d (multi-thread)\uff0c\u53ef\u80fd\u53d1\u751f\u4e24\u4e2a\u8fdb\u7a0b\u540c\u65f6\u68c0\u67e5\u5e76\u53d1\u73b0\u6570\u636e\u4e0d\u5b58\u5728\uff0c\u5bfc\u81f4\u4e24\u8005\u90fd Insert \u5e76\u5f15\u8d77\u91cd\u590d\u9519\u8bef\u3002.<\/li>\n<\/ul>\n<h2>\u89e3\u51b3\u65b9\u6848\uff1a\u81ea\u5b9a\u4e49 Supabase Upsert \u8282\u70b9<\/h2>\n<p>\u8282\u70b9 <strong>Supabase Upsert<\/strong> \u81ea\u5b9a\u4e49\u8282\u70b9\u65e8\u5728\u5b8c\u5168\u6d88\u9664\u4e0a\u8ff0\u590d\u6742\u6027\u3002\u5b83\u5c06\u6574\u4e2a\u201c\u68c0\u67e5\u548c\u51b3\u7b56\u201d\u903b\u8f91\u5c01\u88c5\u6210\u6570\u636e\u5e93\u7ea7\u522b (Database level) \u7684\u5355\u4e00\u64cd\u4f5c\u3002.<\/p>\n<p>\u4ee3\u66ff n8n \u201c\u8be2\u95ee\u201d Supabase \u540e\u518d\u201c\u6267\u884c\u201d\uff0cn8n \u53ea\u9700\u201c\u4e0b\u4ee4\u201d\uff1a <strong>\u201c\u786e\u4fdd\u6b64\u6570\u636e\u5728\u8868\u4e2d\uff0c\u5982\u679c\u5df2\u5b58\u5728\u5219\u66f4\u65b0\uff0c\u4e0d\u5b58\u5728\u5219\u65b0\u5efa\u201d<\/strong>. \u3002Supabase \u5c06\u5904\u7406\u5176\u4f59\u90e8\u5206\u3002.<\/p>\n<h3>\u4e3a\u4ec0\u4e48\u8fd9\u4e2a\u8282\u70b9\u66f4\u4f18\u79c0\uff1f<\/h3>\n<ol>\n<li><strong>\u6700\u5927\u6027\u80fd<\/strong>: \u5c06 API \u8c03\u7528\u6570\u91cf\u51cf\u5c11\u4e00\u534a\uff0c\u751a\u81f3\u5728\u6279\u91cf\u6a21\u5f0f\u4e0b\u51cf\u5c11 1000 \u500d\u3002.<\/li>\n<li><strong>\u7b80\u5316\u5de5\u4f5c\u6d41<\/strong>: \u7528\u5355\u4e2a\u8282\u70b9\u66ff\u6362 3-4 \u4e2a\u590d\u6742\u8282\u70b9\u3002.<\/li>\n<li><strong>\u539f\u5b50\u6027 (Atomicity)<\/strong>: \u786e\u4fdd\u6570\u636e\u5b8c\u6574\u6027\uff0c\u907f\u514d\u7ade\u6001\u6761\u4ef6\u9519\u8bef\u3002.<\/li>\n<\/ol>\n<h2>\u7a81\u7834\u6027\u529f\u80fd<\/h2>\n<p>\u8ba9\u6211\u4eec\u6df1\u5165\u5206\u6790\u8be5\u8282\u70b9\u63d0\u4f9b\u7684\u529f\u80fd\uff1a<\/p>\n<h3>1. \u57fa\u4e8e\u552f\u4e00\u952e\u7684\u81ea\u52a8 Upsert<\/h3>\n<p>\u8282\u70b9\u7684\u6838\u5fc3\u529b\u91cf\u5728\u4e8e\u5b9a\u4e49\u8bb0\u5f55\u201c\u8eab\u4efd\u201d\u7684\u80fd\u529b\u3002\u901a\u8fc7\u201cOn Conflict\u201d\u53c2\u6570\uff0c\u60a8\u6307\u5b9a\u5305\u542b\u552f\u4e00\u503c (Unique Key) \u7684\u5217\u3002.<\/p>\n<p>\u4f8b\u5982\uff1a\u5982\u679c\u60a8\u540c\u6b65\u7528\u6237\uff0c\u201cemail\u201d \u662f\u552f\u4e00\u7684\u3002\u60a8\u5728\u201cOn Conflict\u201d\u4e2d\u586b\u5199\u201cemail\u201d\u3002\u5f53 n8n \u53d1\u9001\u4e00\u4e2a email \u4e3a\u201ctest@example.com\u201d\u7684\u7528\u6237\u65f6\uff1a<\/p>\n<ul>\n<li>\u5982\u679c Supabase \u672a\u627e\u5230\u201ctest@example.com\u201d -&gt; \u521b\u5efa\u65b0\u7528\u6237\u3002.<\/li>\n<li>\u5982\u679c\u627e\u5230 -&gt; \u66f4\u65b0\u8be5\u7528\u6237\u7684\u5176\u4ed6\u4fe1\u606f (\u59d3\u540d\u3001\u5e74\u9f84\u3001\u5730\u5740\u2026).<\/li>\n<\/ul>\n<h3>2. \u6279\u91cf\u5904\u7406 (Batch Processing)<\/h3>\n<p>\u8fd9\u662f\u5927\u6570\u636e\u4efb\u52a1\u7684\u201c\u6740\u624b\u7ea7\u201d\u529f\u80fd\u3002\u5f53\u60a8\u542f\u7528\u9009\u9879 <strong>\u53d1\u9001\u6240\u6709\u9879\u76ee<\/strong>, \u8282\u70b9\u4e0d\u4f1a\u9010\u884c\u53d1\u9001\u3002\u76f8\u53cd\uff0c\u5b83\u5c06\u6240\u6709\u8f93\u5165\u9879\u76ee\uff08\u4f8b\u5982\uff1a5000 \u4e2a\u4ea7\u54c1\uff09\u6536\u96c6\u6210\u4e00\u4e2a\u5de8\u5927\u7684 JSON \u6570\u7ec4\uff0c\u5e76\u5728 <strong>\u4e00\u4e2a\u5355\u4e00\u8bf7\u6c42\u4e2d\u53d1\u9001<\/strong>.<\/p>\n<p>\u8fd9\u53ef\u4ee5\u5c06\u8fd0\u884c\u65f6\u95f4\u4ece\u51e0\u5206\u949f\u51cf\u5c11\u5230\u4ec5\u51e0\u79d2\u949f\u3002.<\/p>\n<h3>3. \u51b2\u7a81\u89e3\u51b3\u7b56\u7565 (Conflict Resolution)<\/h3>\n<p>\u5e76\u975e\u6bcf\u6b21\u66f4\u65b0\u90fd\u662f\u4f60\u60f3\u8981\u7684\u3002\u8282\u70b9\u63d0\u4f9b 2 \u79cd\u7b56\u7565\uff1a<\/p>\n<ul>\n<li><strong>\u5408\u5e76\uff08\u9ed8\u8ba4\uff09<\/strong>: \u6807\u51c6\u7684 Upsert \u884c\u4e3a\u3002\u65b0\u6570\u636e\u5c06\u8986\u76d6\u65e7\u6570\u636e\u3002\u9002\u5408\u540c\u6b65\u6700\u65b0\u72b6\u6001\u3002.<\/li>\n<li><strong>\u5ffd\u7565<\/strong>: \u201c\u4fdd\u6301\u539f\u6837\u201d\u3002\u5982\u679c\u6570\u636e\u5df2\u5b58\u5728\uff0cSupabase \u5c06\u4ec0\u4e48\u90fd\u4e0d\u505a\uff0c\u53ea\u63d2\u5165\u65b0\u884c\u3002\u9002\u5408\u5bfc\u5165\u5386\u53f2\u6570\u636e\u6216\u65e5\u5fd7\uff0c\u5728\u90a3\u91cc\u4f60\u4e0d\u60f3\u66f4\u6539\u5df2\u8bb0\u5f55\u7684\u5185\u5bb9\u3002.<\/li>\n<\/ul>\n<h3>4. \u7075\u6d3b\u6570\u636e\u6e90<\/h3>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u6765\u81ea\u7684\u6570\u636e\uff1a<\/p>\n<ul>\n<li><strong>\u8f93\u5165\u9879\u76ee<\/strong>: \u6765\u81ea n8n \u4e2d\u524d\u4e00\u4e2a\u8282\u70b9\u7684\u6807\u51c6\u6570\u636e\u6d41\u3002.<\/li>\n<li><strong>\u539f\u59cb JSON<\/strong>: \u76f4\u63a5\u8f93\u5165 JSON \u5b57\u7b26\u4e32\u6216\u4f7f\u7528\u8868\u8fbe\u5f0f\u81ea\u5b9a\u4e49\u590d\u6742\u6570\u636e\u7ed3\u6784\uff0c\u800c\u65e0\u9700\u5728\u4e4b\u524d\u4f7f\u7528 \u201cFunction\u201d \u6216 \u201cSet\u201d \u8282\u70b9\u3002.<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/dps.media\/wp-content\/uploads\/mcp\/2026\/01\/supabase_node_ui_1767946325524.jpg\" alt=\"\u8bbe\u7f6e\u754c\u9762\" title=\"\"><\/p>\n<h2>\u8be6\u7ec6\u7684\u5206\u6b65\u914d\u7f6e\u6307\u5357<\/h2>\n<p>\u4e3a\u4e86\u5e2e\u52a9\u60a8\u638c\u63e1\u6b64\u8282\u70b9\uff0c\u8bf7\u9010\u4e00\u4e86\u89e3\u6bcf\u4e2a\u914d\u7f6e\u53c2\u6570\uff1a<\/p>\n<h3>\u6b65\u9aa4 1\uff1a\u8fde\u63a5 (\u51ed\u8bc1)<\/h3>\n<p>\u60a8\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u65b0\u51ed\u8bc1\u7c7b\u578b \u201cSupabase Upsert API\u201d\u3002.<\/p>\n<ul>\n<li><strong>\u9879\u76ee URL<\/strong>: \u5728 Supabase \u4eea\u8868\u677f\u7684 Settings -&gt; API \u4e2d\u67e5\u627e\u3002\u683c\u5f0f\u4e3a \u201chttps:\/\/xyz.supabase.co\u201d\u3002.<\/li>\n<li><strong>\u670d\u52a1\u89d2\u8272\u5bc6\u94a5<\/strong>: <strong>\u91cd\u8981\u63d0\u793a<\/strong>, \u60a8\u5e94\u8be5\u4f7f\u7528 \u201cservice_role\u201d \u5bc6\u94a5\u800c\u4e0d\u662f \u201canon\u201d \u5bc6\u94a5\uff0c\u4ee5\u4fbf\u5728\u9700\u8981\u65f6\u7ed5\u8fc7 RLS (Row Level Security) \u5e76\u6267\u884c\u4e0d\u53d7\u6743\u9650\u9650\u5236\u7684\u6279\u91cf\u5199\u5165\u64cd\u4f5c\u3002.<\/li>\n<\/ul>\n<h3>\u6b65\u9aa4 2\uff1a\u9009\u62e9\u8868 (Table)<\/h3>\n<p>\u8fde\u63a5\u540e\uff0c\u8282\u70b9\u5c06\u81ea\u52a8\u52a0\u8f7d\u60a8\u6570\u636e\u5e93\u4e2d\u7684\u8868\u5217\u8868\u3002\u8bf7\u9009\u62e9\u6b63\u786e\u7684\u76ee\u6807\u8868\uff0c\u4f8b\u5982 \u201cproducts\u201d \u6216 \u201ccustomers\u201d\u3002.<\/p>\n<h3>\u6b65\u9aa4 3\uff1a\u914d\u7f6e Upsert (\u6700\u91cd\u8981)<\/h3>\n<ul>\n<li><strong>\u51b2\u7a81\u65f6<\/strong>: \u8f93\u5165\u5177\u6709\u552f\u4e00\u7ea6\u675f (Unique Constraint) \u7684\u5217\u540d\u3002.\n<ul>\n<li><strong>\u63d0\u793a<\/strong>: \u5982\u679c\u60a8\u4f7f\u7528\u590d\u5408\u4e3b\u952e (Composite Key\uff0c\u4f8b\u5982\uff1aorder_id + product_id)\uff0c\u8bf7\u7528\u9017\u53f7\u5206\u9694\u8f93\u5165\u5b83\u4eec\uff1aorder_id, product_id\u3002.<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u89e3\u6790<\/strong>:\n<ul>\n<li>\u9009\u62e9 \u201c\u5408\u5e76\u201d \u4ee5\u59cb\u7ec8\u66f4\u65b0\u6700\u65b0\u503c\u3002.<\/li>\n<li>\u9009\u62e9 \u201c\u5ffd\u7565\u201d \u5982\u679c\u60a8\u53ea\u60f3\u63d2\u5165\u65b0\u6570\u636e\u3002.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>\u6b65\u9aa4 4\uff1a\u9ad8\u7ea7\u9009\u9879<\/h3>\n<ul>\n<li><strong>\u8fd4\u56de<\/strong>: \u9009\u62e9 \u201cRepresentation\u201d \u4ee5\u8ba9\u8282\u70b9\u8fd4\u56de\u521a\u521a\u63d2\u5165\/\u66f4\u65b0\u7684\u6570\u636e\uff08\u6709\u52a9\u4e8e\u83b7\u53d6\u81ea\u589e ID\uff09\u3002\u9009\u62e9 \u201cMinimal\u201d \u5982\u679c\u60a8\u4e0d\u5173\u5fc3\u8fd4\u56de\u7ed3\u679c\u4ee5\u8282\u7701\u7f51\u7edc\u5e26\u5bbd\u3002.<\/li>\n<\/ul>\n<h2>\u5b9e\u9645\u5e94\u7528\u573a\u666f (Use Cases)<\/h2>\n<h3>\u573a\u666f 1\uff1a\u7535\u5546\u5e93\u5b58\u540c\u6b65 (\u9ad8\u5bb9\u91cf)<\/h3>\n<p>\u60a8\u6709\u4e00\u4e2a\u5305\u542b 10.000 \u4e2a\u6765\u81ea\u603b\u4ed3\u5e93\u7684\u4ea7\u54c1 CSV \u6587\u4ef6\uff0c\u6bcf\u5c0f\u65f6\u66f4\u65b0\u4e00\u6b21\u3002.<\/p>\n<ul>\n<li><strong>\u914d\u7f6e<\/strong>:\n<ul>\n<li>\u8868\uff1a \u201cinventory\u201d<\/li>\n<li>On Conflict: \u201csku\u201d (SKU)<\/li>\n<li>Resolution: \u201cMerge\u201d<\/li>\n<li>Send All Items: \u201cTrue\u201d<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u7ed3\u679c<\/strong>: \u66f4\u65b010,000\u4e2a\u4ea7\u54c1\u7684\u5e93\u5b58\u6570\u91cf\u4ec5\u97001-2\u79d2\u3002\u65b0SKU\u5c06\u81ea\u52a8\u6dfb\u52a0\u5230\u9500\u552e\u7cfb\u7edf\u4e2d\u3002.<\/li>\n<\/ul>\n<h3>\u573a\u666f 2\uff1a\u4ece\u767b\u9646\u9875\u9762\u6536\u96c6\u6f5c\u5728\u5ba2\u6237<\/h3>\n<p>\u60a8\u5728\u591a\u4e2a\u6e20\u9053\u6295\u653e\u5e7f\u544a\uff0c\u6570\u636e\u901a\u8fc7Webhook\u6d41\u5165\u3002\u540c\u4e00\u5ba2\u6237\u53ef\u80fd\u591a\u6b21\u6ce8\u518c\u3002.<\/p>\n<ul>\n<li><strong>\u914d\u7f6e<\/strong>:\n<ul>\n<li>Table: \u201cleads\u201d<\/li>\n<li>On Conflict: \u201cemail\u201d<\/li>\n<li>Resolution: \u201cIgnore\u201d<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u7ed3\u679c<\/strong>: \u60a8\u4ec5\u4fdd\u7559\u9996\u6b21\u6ce8\u518c\u4fe1\u606f\uff08First Touch Attribution\uff09\u3002\u540e\u7eed\u6ce8\u518c\u5c06\u88ab\u5ffd\u7565\uff0c\u907f\u514d\u7a00\u91caCRM\u6570\u636e\u3002.<\/li>\n<\/ul>\n<h3>\u573a\u666f 3\uff1aIoT \u4f20\u611f\u5668\u65e5\u5fd7\u8bb0\u5f55<\/h3>\n<p>\u4f20\u611f\u5668\u7cfb\u7edf\u6bcf5\u5206\u949f\u53d1\u9001\u4e00\u6b21\u6e29\u5ea6\u6570\u636e\u3002\u6709\u65f6\u7f51\u7edc\u4e0d\u7a33\u5b9a\uff0c\u4f20\u611f\u5668\u4f1a\u91cd\u65b0\u53d1\u9001\u65e7\u6570\u636e\u5305\u3002.<\/p>\n<ul>\n<li><strong>\u914d\u7f6e<\/strong>:\n<ul>\n<li>Table: \u201csensor_readings\u201d<\/li>\n<li>On Conflict: \u201cdevice_id, timestamp\u201d<\/li>\n<li>Resolution: \u201cMerge\u201d<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u7ed3\u679c<\/strong>: \u786e\u4fdd\u540c\u4e00\u65f6\u95f4\uff0c\u6bcf\u4e2a\u8bbe\u5907\u53ea\u6709\u4e00\u4e2a\u8bb0\u5f55\u3002\u5982\u679c\u6570\u636e\u91cd\u53d1\uff0c\u5b83\u5c06\u8986\u76d6\u65e7\u8bb0\u5f55\uff08\u901a\u5e38\u76f8\u540c\uff09\uff0c\u4fdd\u6301\u6570\u636e\u5e93\u6574\u6d01\u3002.<\/li>\n<\/ul>\n<h2>\u5e38\u89c1\u6ce8\u610f\u4e8b\u9879\u548c\u98ce\u9669<\/h2>\n<ol>\n<li><strong>\u201cOn Conflict\u201d\u9519\u8bef\u201d<\/strong>: \u5982\u679c\u60a8\u8f93\u5165\u9519\u8bef\u7684\u5217\u540d\u6216\u8be5\u5217\u5728\u6570\u636e\u5e93\u4e2d\u6ca1\u6709\u201cUNIQUE\u201d\u7ea6\u675f\uff0cSupabase\u5c06\u62a5\u9519\u3002\u8bf7\u786e\u4fdd\u5728SQL Editor\u4e2d\u4e3a\u8be5\u5217\u521b\u5efaUnique Index\u3002.\n<ul>\n<li><strong>SQL\u521b\u5efa\u7d22\u5f15<\/strong>: CREATE UNIQUE INDEX idx_users_email ON public.users (email);<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u8bf7\u6c42\u5927\u5c0f\u9650\u5236<\/strong>: \u5c3d\u7ba1\u201cSend All Items\u201d\u975e\u5e38\u5f3a\u5927\uff0c\u4f46Supabase\u6709body\u5927\u5c0f\u9650\u5236\uff08\u901a\u5e38\u51e0MB\uff09\u3002\u4e00\u6b21\u6027\u53d1\u9001100,000\u884c\u53ef\u80fd\u51fa\u9519\u3002\u8bf7\u5206\u6279\uff08Split in Batches\uff09\u62101,000\u20135,000\u884c\u7684\u5c0f\u7ec4\u3002.<\/li>\n<li><strong>\u8bbf\u95ee\u6743\u9650 (RLS)<\/strong>: \u5982\u679c\u4f7f\u7528\u201canon\u201d key\uff0c\u8bf7\u786e\u4fdd\u5df2\u914d\u7f6eRow Level Security\u5141\u8bb8Insert\/Update\u3002\u5bf9\u4e8e\u540e\u7aef\u5de5\u4f5c\u6d41\uff0c\u6700\u597d\u4f7f\u7528\u201cservice_role\u201d key\u3002.<\/li>\n<\/ol>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u8282\u70b9 <strong>Supabase Upsert<\/strong> \u4e0d\u4ec5\u4ec5\u662f\u4e00\u4e2a\u5b9e\u7528\u5de5\u5177\uff0c\u5b83\u662fn8n\u4e2d\u9ad8\u6027\u80fd\u6570\u636e\u96c6\u6210\u6d41\u7a0b\u7684\u201c\u9aa8\u5e72\u201d\u3002\u6b63\u786e\u7406\u89e3\u548c\u5e94\u7528\u6b64\u8282\u70b9\u5c06\u4e3a\u60a8\u8282\u7701\u6570\u5c0f\u65f6\u8c03\u8bd5\u65f6\u95f4\uff0c\u51cf\u8f7b\u670d\u52a1\u5668\u8d1f\u8f7d\uff0c\u5e76\u4e3a\u7cfb\u7edf\u5e26\u6765\u6d41\u7545\u4f53\u9a8c\u3002.<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u6784\u5efa\u4e0eSupabase\u7684\u590d\u6742\u81ea\u52a8\u5316\u7cfb\u7edf\uff0c\u8fd9\u7edd\u5bf9\u662f\u60a8\u4e0d\u80fd\u9519\u8fc7\u7684\u8282\u70b9\u3002\u7acb\u5373\u5b89\u88c5\u3001\u4f53\u9a8c\u5e76\u611f\u53d7\u5353\u8d8a\u7684\u901f\u5ea6\uff01<\/p>\n<style>\r\n.lwrp.link-whisper-related-posts{\r\n            \r\n            margin-top: 40px;\nmargin-bottom: 30px;\r\n        }\r\n        .lwrp .lwrp-title{\r\n            \r\n            \r\n        }.lwrp .lwrp-description{\r\n            \r\n            \r\n\r\n        }\r\n        .lwrp .lwrp-list-container{\r\n        }\r\n        .lwrp .lwrp-list-multi-container{\r\n            display: flex;\r\n        }\r\n        .lwrp .lwrp-list-double{\r\n            width: 48%;\r\n        }\r\n        .lwrp .lwrp-list-triple{\r\n            width: 32%;\r\n        }\r\n        .lwrp .lwrp-list-row-container{\r\n            display: flex;\r\n            justify-content: space-between;\r\n        }\r\n        .lwrp .lwrp-list-row-container .lwrp-list-item{\r\n            width: calc(33% - 20px);\r\n        }\r\n        .lwrp .lwrp-list-item:not(.lwrp-no-posts-message-item){\r\n            \r\n            max-width: 150px;\r\n        }\r\n        .lwrp .lwrp-list-item img{\r\n            max-width: 100%;\r\n            height: auto;\r\n            object-fit: cover;\r\n            aspect-ratio: 1 \/ 1;\r\n        }\r\n        .lwrp .lwrp-list-item.lwrp-empty-list-item{\r\n            background: initial !important;\r\n        }\r\n        .lwrp .lwrp-list-item .lwrp-list-link .lwrp-list-link-title-text,\r\n        .lwrp .lwrp-list-item .lwrp-list-no-posts-message{\r\n            \r\n            \r\n            \r\n            \r\n        }@media screen and (max-width: 480px) {\r\n            .lwrp.link-whisper-related-posts{\r\n                \r\n                \r\n            }\r\n            .lwrp .lwrp-title{\r\n                \r\n                \r\n            }.lwrp .lwrp-description{\r\n                \r\n                \r\n            }\r\n            .lwrp .lwrp-list-multi-container{\r\n                flex-direction: column;\r\n            }\r\n            .lwrp .lwrp-list-multi-container ul.lwrp-list{\r\n                margin-top: 0px;\r\n                margin-bottom: 0px;\r\n                padding-top: 0px;\r\n                padding-bottom: 0px;\r\n            }\r\n            .lwrp .lwrp-list-double,\r\n            .lwrp .lwrp-list-triple{\r\n                width: 100%;\r\n            }\r\n            .lwrp .lwrp-list-row-container{\r\n                justify-content: initial;\r\n                flex-direction: column;\r\n            }\r\n            .lwrp .lwrp-list-row-container .lwrp-list-item{\r\n                width: 100%;\r\n            }\r\n            .lwrp .lwrp-list-item:not(.lwrp-no-posts-message-item){\r\n                \r\n                max-width: initial;\r\n            }\r\n            .lwrp .lwrp-list-item .lwrp-list-link .lwrp-list-link-title-text,\r\n            .lwrp .lwrp-list-item .lwrp-list-no-posts-message{\r\n                \r\n                \r\n                \r\n                \r\n            };\r\n        }<\/style>\r\n<div id=\"link-whisper-related-posts-widget\" class=\"link-whisper-related-posts lwrp\">\r\n            <div class=\"lwrp-title\">\u76f8\u5173\u6587\u7ae0<\/div>    \r\n        <div class=\"lwrp-list-container\">\r\n                                <div class=\"lwrp-list lwrp-list-row-container lwrp-list-double-row\">\r\n                <div class=\"lwrp-list-item\"><a href=\"https:\/\/dps.media\/zh\/%e8%b6%8a%e5%8d%97%e6%ad%a3%e5%bc%8f%e9%a2%81%e5%b8%83%e4%ba%ba%e5%b7%a5%e6%99%ba%e8%83%bdai%e6%b3%95\/\" class=\"lwrp-list-link\"><span class=\"lwrp-list-link-title-text\">\u8d8a\u5357\u6b63\u5f0f\u9881\u5e03\u4eba\u5de5\u667a\u80fdAI\u6cd5<\/span><\/a><\/div><div class=\"lwrp-list-item\"><a href=\"https:\/\/dps.media\/zh\/kol%e7%a7%9f%e9%87%91-4%e4%b8%aa%e9%87%8d%e8%a6%81%e5%86%b3%e5%ae%9a%e5%9b%a0%e7%b4%a0\/\" class=\"lwrp-list-link\"><span class=\"lwrp-list-link-title-text\">KOL\u79df\u8d41\u4ef7\u683c\u2014\u20144\u4e2a\u5173\u952e\u51b3\u5b9a\u56e0\u7d20<\/span><\/a><\/div><div class=\"lwrp-list-item\"><a href=\"https:\/\/dps.media\/zh\/%e6%9e%84%e5%bb%ba%e7%ac%a6%e5%90%88seo%e6%a0%87%e5%87%86%e7%9a%84shopee%e9%ab%98%e6%8e%92%e5%90%8d%e7%a7%98%e8%af%80\/\" class=\"lwrp-list-link\"><span class=\"lwrp-list-link-title-text\">\u6253\u9020\u7b26\u5408SEO\u6807\u51c6\u7684Shopee\u9ad8\u6392\u540d\u79d8\u8bc0<\/span><\/a><\/div>                <\/div>\r\n                            <div class=\"lwrp-list lwrp-list-row-container lwrp-list-double-row\">\r\n                <div class=\"lwrp-list-item\"><a href=\"https:\/\/dps.media\/zh\/%e5%89%8d5%e5%90%8d%e9%a2%84%e8%ae%a2pr%e6%96%87%e7%ab%a0%e6%97%b6%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a1%b9%ef%bc%8c%e4%bb%a5%e4%b8%8d%e6%b5%aa%e8%b4%b9%e9%a2%84%e7%ae%97\/\" class=\"lwrp-list-link\"><span class=\"lwrp-list-link-title-text\">\u9884\u8ba2PR\u6587\u7ae0\u65f6\u76845\u5927\u6ce8\u610f\u4e8b\u9879\uff0c\u907f\u514d\u9884\u7b97\u6d6a\u8d39<\/span><\/a><\/div><div class=\"lwrp-list-item\"><a href=\"https:\/\/dps.media\/zh\/%e5%bf%ab%e9%80%9f%e9%83%a8%e7%bd%b2-google-ai-studio-%e5%ba%94%e7%94%a8%e5%88%b0%e6%89%98%e7%ae%a1%e5%92%8c%e8%87%aa%e5%ae%9a%e4%b9%89%e5%9f%9f%e5%90%8d%e4%b8%ba%e4%bc%81%e4%b8%9a\/\" class=\"lwrp-list-link\"><span class=\"lwrp-list-link-title-text\">\u5feb\u901f\u90e8\u7f72 Google AI Studio \u5e94\u7528\u5230\u6258\u7ba1\u548c\u81ea\u5b9a\u4e49\u57df\u540d\uff0c\u4e13\u4e3a\u4f01\u4e1a\u8bbe\u8ba1<\/span><\/a><\/div><div class=\"lwrp-list-item\"><a href=\"https:\/\/dps.media\/zh\/tiktok-studio-%e5%88%9b%e4%bd%9c%e8%80%85%e8%af%a6%e7%bb%86%e4%bd%bf%e7%94%a8%e6%8c%87%e5%8d%97\/\" class=\"lwrp-list-link\"><span class=\"lwrp-list-link-title-text\">TikTok Studio \u521b\u4f5c\u8005\u8be6\u7ec6\u4f7f\u7528\u6307\u5357<\/span><\/a><\/div>                <\/div>\r\n                <\/div>\r\n<\/div>","protected":false},"excerpt":{"rendered":"<p>{\"translations\":[{\"\u5728\u81ea\u52a8\u5316\u548c\u7cfb\u7edf\u96c6\u6210\uff08system integration\uff09\u7684\u65f6\u4ee3\uff0c\u5728\u4e0d\u540c\u5e73\u53f0\u4e4b\u95f4\u540c\u6b65\u6570\u636e\u662f\u6700\u5e38\u89c1\u7684\u4efb\u52a1\u4e4b\u4e00\uff0c\u4f46\u4e5f\u5145\u6ee1\u6311\u6218\u3002\u60a8\u6709\u4e00\u4e2a\u6765\u81eaCRM\u7684\u5ba2\u6237\u5217\u8868\uff0c\u4e00\u4e2a\u6765\u81eaExcel\u6587\u4ef6\u7684\u5546\u54c1\u8868\u683c\uff0c[\u2026]\"}]}<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1205,1],"tags":[],"class_list":["post-35698","post","type-post","status-publish","format-standard","hentry","category-n8n-marketing","category-uncategorized"],"acf":[],"rankmath_keywords":{"primary":"","secondary":[""]},"yoast_keywords":{"primary":"","secondary":[]},"yoast_focuskw":"","rankmath_focuskw":"","seo_keywords":{"primary":"","secondary":[""]},"_links":{"self":[{"href":"https:\/\/dps.media\/zh\/wp-json\/wp\/v2\/posts\/35698","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dps.media\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dps.media\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dps.media\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dps.media\/zh\/wp-json\/wp\/v2\/comments?post=35698"}],"version-history":[{"count":0,"href":"https:\/\/dps.media\/zh\/wp-json\/wp\/v2\/posts\/35698\/revisions"}],"wp:attachment":[{"href":"https:\/\/dps.media\/zh\/wp-json\/wp\/v2\/media?parent=35698"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dps.media\/zh\/wp-json\/wp\/v2\/categories?post=35698"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dps.media\/zh\/wp-json\/wp\/v2\/tags?post=35698"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}