{"id":123625,"date":"2026-11-07T22:01:12","date_gmt":"2026-11-07T14:01:12","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/123625.html"},"modified":"2026-11-07T22:01:12","modified_gmt":"2026-11-07T14:01:12","slug":"%e6%88%90%e4%b8%ba%e5%85%a8%e6%a0%88%c2%b7%e5%9f%ba%e7%a1%80%e8%a1%a5%e5%85%85%c2%b7node-js-%e8%bf%90%e8%a1%8c%e6%97%b6%ef%bc%9a%e4%ba%8b%e4%bb%b6%e5%be%aa%e7%8e%af%e4%b8%8e%e5%bc%82%e6%ad%a5","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/123625.html","title":{"rendered":"\u6210\u4e3a\u5168\u6808\u00b7\u57fa\u7840\u8865\u5145\u00b7Node.js \u8fd0\u884c\u65f6\uff1a\u4e8b\u4ef6\u5faa\u73af\u4e0e\u5f02\u6b65"},"content":{"rendered":"<h2>\u6210\u4e3a\u5168\u6808\u00b7\u57fa\u7840\u8865\u5145\u00b7Node.js \u8fd0\u884c\u65f6&#xff1a;\u4e8b\u4ef6\u5faa\u73af\u4e0e\u5f02\u6b65<\/h2>\n<p>\u8fd9\u4e2a\u9879\u76ee\u91cc\u6709\u4e00\u6bb5\u4ee3\u7801&#xff0c;\u5b83\u7684\u5916\u5f62\u662f async&#xff0c;\u4f46\u5185\u90e8\u8c03\u7528\u7684\u662f\u4e00\u4e2a\u540c\u6b65\u51fd\u6570&#xff1a;<\/p>\n<p><span class=\"token comment\">\/** \u540c\u4e00\u6279 SQL \u5728 SQLite \u4e8b\u52a1\u6216 D1 batch \u4e2d\u6267\u884c&#xff1b;\u5f02\u5e38\u6574\u4f53\u56de\u6eda\u3002 *\/<\/span><br \/>\n<span class=\"token keyword\">export<\/span> <span class=\"token keyword\">async<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function\">atomic<\/span><span class=\"token punctuation\">(<\/span>db<span class=\"token operator\">:<\/span> Db<span class=\"token punctuation\">,<\/span> statements<span class=\"token operator\">:<\/span> Statement<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token operator\">:<\/span> <span class=\"token builtin\">Promise<\/span><span class=\"token operator\">&lt;<\/span><span class=\"token builtin\">number<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token operator\">&gt;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">const<\/span> client <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span>db <span class=\"token keyword\">as<\/span> <span class=\"token builtin\">unknown<\/span> <span class=\"token keyword\">as<\/span> <span class=\"token punctuation\">{<\/span> $client<span class=\"token operator\">:<\/span> Database<span class=\"token punctuation\">.<\/span>Database <span class=\"token operator\">|<\/span> D1Client <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>$client<span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;batch&#039;<\/span> <span class=\"token keyword\">in<\/span> client<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">const<\/span> results <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> client<span class=\"token punctuation\">.<\/span><span class=\"token function\">batch<\/span><span class=\"token punctuation\">(<\/span><br \/>\n      statements<span class=\"token punctuation\">.<\/span><span class=\"token function\">map<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>s<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> client<span class=\"token punctuation\">.<\/span><span class=\"token function\">prepare<\/span><span class=\"token punctuation\">(<\/span>s<span class=\"token punctuation\">.<\/span>sql<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">bind<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&#8230;<\/span>s<span class=\"token punctuation\">.<\/span>params<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> results<span class=\"token punctuation\">.<\/span><span class=\"token function\">map<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>r<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> r<span class=\"token punctuation\">.<\/span>meta<span class=\"token punctuation\">.<\/span>changes<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n  <span class=\"token keyword\">return<\/span> client<span class=\"token punctuation\">.<\/span><span class=\"token function\">transaction<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span><br \/>\n    statements<span class=\"token punctuation\">.<\/span><span class=\"token function\">map<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>s<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> client<span class=\"token punctuation\">.<\/span><span class=\"token function\">prepare<\/span><span class=\"token punctuation\">(<\/span>s<span class=\"token punctuation\">.<\/span>sql<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">run<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&#8230;<\/span>s<span class=\"token punctuation\">.<\/span>params<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>changes<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n  <span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u4e00\u4e2a async \u51fd\u6570&#xff0c;\u5374\u5728\u672c\u5730\u8def\u5f84\u4e0a\u5b8c\u5168\u540c\u6b65\u6267\u884c\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261107140107-6aef2f23063da.png\" alt=\"\u6210\u4e3a\u5168\u6808\u00b7\u57fa\u7840\u8865\u5145\u00b7Node.js \u8fd0\u884c\u65f6\uff1a\u4e8b\u4ef6\u5faa\u73af\u4e0e\u5f02\u6b65\" \/><\/p>\n<p>\u8fd9\u5728 TypeScript \u91cc\u5408\u6cd5&#xff08;async \u51fd\u6570\u8fd4\u56de Promise&#xff0c;\u91cc\u9762\u53ef\u4ee5\u662f\u540c\u6b65\u903b\u8f91&#xff09;&#xff0c;\u4f46\u5b83\u7acb\u523b\u5e26\u6765\u4e00\u4e2a\u95ee\u9898&#xff1a;\u8c03\u7528\u65b9\u80fd\u5047\u8bbe\u5b83\u662f\u5f02\u6b65\u7684\u5417&#xff1f;<\/p>\n<p>\u7b54\u6848\u662f\u4e0d\u80fd\u3002\u800c\u8fd9\u4e2a\u9879\u76ee\u91cc\u6709\u4e00\u6574\u7c7b\u4ee3\u7801&#xff0c;\u4e13\u95e8\u5904\u7406&#034;\u6211\u4e0d\u786e\u5b9a\u90a3\u4e2a Promise \u4f1a\u4e0d\u4f1a\u5df2\u7ecf\u7ed3\u675f&#034;\u3002<\/p>\n<p>\u8fd9\u7bc7\u8bb2\u8fd9\u4e2a\u9879\u76ee\u7684 Node \u8fd0\u884c\u65f6\u7ecf\u9a8c&#xff0c;\u4ee5\u53ca\u4e3a\u4ec0\u4e48 Flutter \u90a3\u8fb9\u7684\u6bcf\u4e00\u5904\u5f02\u6b65\u90fd\u8981\u8bb0\u8eab\u4efd&#xff08;M4-09 \u90a3\u4e9b epoch \u68c0\u67e5&#xff0c;\u5176\u5b9e\u6839\u6e90\u5728\u8fd9\u91cc&#xff09;\u3002<\/p>\n<h3>\u5355\u7ebf\u7a0b\u610f\u5473\u7740&#xff1a;await \u4e4b\u95f4\u7684\u4ee3\u7801\u4f1a\u88ab\u63d2\u961f<\/h3>\n<p>\u5148\u628a\u6700\u5173\u952e\u7684\u524d\u63d0\u8bf4\u6e05\u695a&#xff0c;\u56e0\u4e3a\u5b83\u89e3\u91ca\u4e86\u540e\u9762\u6240\u6709\u7684\u590d\u6742\u5ea6\u3002<\/p>\n<p>Node \u7684 JavaScript \u6267\u884c\u662f\u5355\u7ebf\u7a0b\u7684\u3002 \u800c\u5355\u7ebf\u7a0b\u4e0d\u4ee3\u8868&#034;\u987a\u5e8f\u6267\u884c\u5230\u5e95&#034;\u2014\u2014\u5b83\u4ee3\u8868\u7684\u662f&#xff1a;<\/p>\n<p>\u4e00\u6b21\u53ea\u6267\u884c\u4e00\u6bb5\u4ee3\u7801&#xff0c;\u4f46\u4f1a\u5728 await \u8fd9\u4e9b\u8ba9\u51fa\u70b9\u4e3b\u52a8\u628a\u63a7\u5236\u6743\u4ea4\u51fa\u53bb\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261107140108-6aef2f2412287.png\" alt=\"\u4e8b\u4ef6\u5faa\u73af\" \/><\/p>\n<p>\u800c&#034;\u8ba9\u51fa\u70b9&#034;\u5177\u4f53\u662f\u54ea\u4e9b&#xff0c;\u53d6\u51b3\u4e8e\u5177\u4f53\u662f\u4ec0\u4e48\u64cd\u4f5c&#xff1a;<\/p>\n<table>\n<tr>\u64cd\u4f5c\u4f1a\u4e0d\u4f1a\u8ba9\u51fa<\/tr>\n<tbody>\n<tr>\n<td>\u8bfb\u53d6\u6587\u4ef6&#xff08;fs.readFile&#xff09;<\/td>\n<td>\u4f1a&#xff0c;\u6587\u4ef6\u5728\u78c1\u76d8\u4e0a&#xff0c;\u5f97\u7b49 I\/O \u5b8c\u6210<\/td>\n<\/tr>\n<tr>\n<td>\u7f51\u7edc\u8bf7\u6c42&#xff08;fetch&#xff09;<\/td>\n<td>\u4f1a&#xff0c;\u8981\u7b49\u5bf9\u7aef\u54cd\u5e94<\/td>\n<\/tr>\n<tr>\n<td>\u6570\u636e\u5e93\u67e5\u8be2<\/td>\n<td>\u4f1a&#xff0c;\u6570\u636e\u53ef\u80fd\u5728\u8fdc\u7aef<\/td>\n<\/tr>\n<tr>\n<td>\u7eaf\u8ba1\u7b97&#xff08;\u6392\u5e8f\u3001\u5927\u5faa\u73af&#xff09;<\/td>\n<td>\u4e0d\u4f1a&#xff0c;\u4e00\u76f4\u5360\u7740<\/td>\n<\/tr>\n<tr>\n<td>\u5b9a\u65f6\u5668&#xff08;setTimeout&#xff09;<\/td>\n<td>\u4f1a\u7b49&#xff0c;\u4f46\u7b49\u7684\u662f\u65f6\u95f4<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u800c&#034;\u8ba9\u51fa&#034;\u671f\u95f4&#xff0c;\u540c\u4e00\u4e2a\u7ebf\u7a0b\u4f1a\u53bb\u5904\u7406\u522b\u7684\u4e8b\u2014\u2014\u5305\u62ec\u53e6\u4e00\u4e2a\u8bf7\u6c42\u7684\u4ee3\u7801\u3002<\/p>\n<p>\u8fd9\u5c31\u662f\u4e8b\u4ef6\u5faa\u73af\u7684\u6838\u5fc3&#xff0c;\u4e5f\u662f\u6240\u6709\u5f02\u6b65 bug \u7684\u6839\u6e90\u3002<\/p>\n<h3>\u4e00\u4e2a\u5fc5\u987b\u8bb0\u4f4f\u7684\u540e\u679c&#xff1a;await \u4e4b\u540e\u7684\u4e16\u754c\u53ef\u80fd\u53d8\u4e86<\/h3>\n<p>\u7528\u4e00\u4e2a\u771f\u5b9e\u573a\u666f\u8bf4\u660e\u3002\u770b\u8fd9\u4e2a\u9879\u76ee\u7684\u5237\u65b0\u903b\u8f91&#xff08;\u7b80\u5316&#xff09;&#xff1a;<\/p>\n<p>Future<span class=\"token operator\">&lt;<\/span><span class=\"token keyword\">void<\/span><span class=\"token operator\">&gt;<\/span> <span class=\"token function\">refresh<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>_refresh <span class=\"token operator\">!&#061;<\/span> <span class=\"token keyword\">null<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">return<\/span> _refresh<span class=\"token operator\">!<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  final start <span class=\"token operator\">&#061;<\/span> epoch<span class=\"token punctuation\">;<\/span><br \/>\n  final task <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> async <span class=\"token punctuation\">{<\/span><br \/>\n    final token <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> vault<span class=\"token punctuation\">.<\/span><span class=\"token function\">read<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>          <span class=\"token comment\">\/\/ \u2190 \u7b2c\u4e00\u6b21\u8ba9\u51fa<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>start <span class=\"token operator\">!&#061;<\/span> epoch<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">throw<\/span> <span class=\"token function\">SessionChanged<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u2190 \u68c0\u67e5\u4e16\u754c\u6709\u6ca1\u6709\u53d8<\/span><br \/>\n    <span class=\"token operator\">&#8230;<\/span><br \/>\n    final data <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> <span class=\"token function\">request<\/span><span class=\"token punctuation\">(<\/span>Endpoints<span class=\"token punctuation\">.<\/span>refresh<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&#8230;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u2190 \u7b2c\u4e8c\u6b21\u8ba9\u51fa<\/span><br \/>\n    <span class=\"token keyword\">await<\/span> <span class=\"token function\">install<\/span><span class=\"token punctuation\">(<\/span>data<span class=\"token punctuation\">,<\/span> expectedEpoch<span class=\"token operator\">:<\/span> start<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>           <span class=\"token comment\">\/\/ \u2190 \u7b2c\u4e09\u6b21\u8ba9\u51fa<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u4e09\u5904 await&#xff0c;\u4e24\u5904\u68c0\u67e5\u3002<\/p>\n<p>\u800c\u68c0\u67e5\u7684\u5185\u5bb9\u662f start !&#061; epoch\u2014\u2014\u201c\u6211\u53d1\u8d77\u8fd9\u6b21\u64cd\u4f5c\u65f6&#xff0c;\u90a3\u4e2a\u4f1a\u8bdd\u8fd8\u5728\u5417&#xff1f;\u201d<\/p>\n<p>\u4e3a\u4ec0\u4e48\u5fc5\u987b\u68c0\u67e5&#xff1f;\u56e0\u4e3a\u5728\u6bcf\u4e2a await \u5904&#xff0c;\u7528\u6237\u5b8c\u5168\u53ef\u80fd\u5df2\u7ecf\u505a\u4e86\u522b\u7684\u4e8b&#xff1a;<\/p>\n<p>\u65f6\u523b T1&#xff1a;refresh() \u5f00\u59cb&#xff0c;\u8bb0\u4e0b epoch &#061; 3<br \/>\n\u65f6\u523b T1&#043;\u03b5&#xff1a;await vault.read() \u8ba9\u51fa<br \/>\n           \u2193 \u6b64\u65f6\u7528\u6237\u70b9\u4e86&#034;\u9000\u51fa\u767b\u5f55&#034;<br \/>\n           \u2193 clear() \u6267\u884c&#xff0c;epoch \u53d8\u6210 4<br \/>\n\u65f6\u523b T2&#xff1a;await \u8fd4\u56de&#xff0c;\u7ee7\u7eed\u6267\u884c<br \/>\n         \u5982\u679c\u4e0d\u68c0\u67e5 \u2192 \u7528 epoch 3 \u7684\u4e0a\u4e0b\u6587\u5b8c\u6210\u5237\u65b0<br \/>\n         \u7ed3\u679c \u2192 token \u88ab\u5199\u56de\u4e00\u4e2a\u5df2\u7ecf\u767b\u51fa\u7684\u4f1a\u8bdd<\/p>\n<p>\u8fd9\u5c31\u662f Flutter \u90a3\u8fb9\u7684 epoch\u3002\u800c\u5b83\u5728 Node \u8fd9\u8fb9\u540c\u6837\u5b58\u5728\u2014\u2014M1-32 \u90a3\u4e2a\u5fae\u4fe1\u767b\u5f55\u5c31\u662f\u540c\u4e00\u5957&#xff1a;atomic \u91cc\u7684 SessionChanged \u5f02\u5e38\u5904\u7406\u7684\u5c31\u662f\u8fd9\u4e2a\u3002<\/p>\n<p>\u6240\u4ee5\u8fd9\u4e00\u7bc7\u7684\u6838\u5fc3\u7ed3\u8bba\u662f&#xff1a;<\/p>\n<p>\u5728\u5355\u7ebf\u7a0b\u4e8b\u4ef6\u5faa\u73af\u91cc&#xff0c;await \u4e0d\u53ea\u662f&#034;\u7b49\u4e00\u4f1a\u513f&#034;&#xff0c;\u5b83\u662f\u4e00\u4e2a&#034;\u4e16\u754c\u53ef\u80fd\u5df2\u7ecf\u53d8\u4e86&#034;\u7684\u8fb9\u754c\u3002<\/p>\n<p>\u800c\u8fd9\u4e2a\u5224\u65ad\u6807\u51c6\u662f\u901a\u7528\u7684&#xff0c;\u4e0d\u9650\u4e8e\u5f02\u6b65 I\/O&#xff1a;<\/p>\n<table>\n<tr>await \u4e4b\u95f4\u53ef\u80fd\u53d1\u751f\u4ec0\u4e48\u9700\u8981\u68c0\u67e5\u5417<\/tr>\n<tbody>\n<tr>\n<td>\u7528\u6237\u5207\u6362\u4e86\u8d26\u53f7 \/ \u767b\u51fa<\/td>\n<td>\u8981<\/td>\n<\/tr>\n<tr>\n<td>\u7528\u6237\u5173\u95ed\u4e86\u9875\u9762&#xff08;Flutter Widget dispose&#xff09;<\/td>\n<td>\u8981<\/td>\n<\/tr>\n<tr>\n<td>\u9875\u9762\u4ece\u540e\u53f0\u5207\u5230\u524d\u53f0<\/td>\n<td>\u53ef\u80fd\u8981<\/td>\n<\/tr>\n<tr>\n<td>\u5355\u7eaf\u7684\u5b9a\u65f6\u5668\u5230\u671f<\/td>\n<td>\u4e0d\u9700\u8981<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u4e3a\u4ec0\u4e48\u8fd9\u4e2a\u9879\u76ee\u91cc\u7684\u5f02\u6b65\u90fd\u8981&#034;\u8bb0\u8eab\u4efd&#034;<\/h3>\n<p>\u73b0\u5728\u8bb2\u8fd9\u4e2a\u9879\u76ee\u91cc\u53cd\u590d\u51fa\u73b0\u7684\u90a3\u4e2a\u6a21\u5f0f\u3002<\/p>\n<p>M4-12 \u7684\u5217\u8868\u9875&#xff1a;<\/p>\n<p>final ticket <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">&#043;&#043;<\/span>serial<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">setState<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> busy <span class=\"token operator\">&#061;<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">;<\/span> error <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">null<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token operator\">&#8230;<\/span><br \/>\nfinal p <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> repo<span class=\"token punctuation\">.<\/span><span class=\"token function\">track<\/span><span class=\"token punctuation\">(<\/span>dependencies<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> repo<span class=\"token punctuation\">.<\/span><span class=\"token function\">articles<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&#8230;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">!<\/span>mounted <span class=\"token operator\">||<\/span> ticket <span class=\"token operator\">!&#061;<\/span> serial<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">return<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ \u2190 \u8bb0\u4e86\u53f7&#xff0c;\u56de\u6765\u6838\u5bf9<\/span><\/p>\n<p>M4-10 \u7684 AsyncPane&#xff1a;<\/p>\n<p>final ticket <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">&#043;&#043;<\/span>serial<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token operator\">&#8230;<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>mounted <span class=\"token operator\">&amp;&amp;<\/span> ticket <span class=\"token operator\">&#061;&#061;<\/span> serial<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token function\">setState<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> value <span class=\"token operator\">&#061;<\/span> result<span class=\"token punctuation\">;<\/span> error <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">null<\/span><span class=\"token punctuation\">;<\/span> keys <span class=\"token operator\">&#061;<\/span> nextKeys<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>M4-15 \u7684 WebView \u6807\u9898\u8f6e\u8be2&#xff1a;<\/p>\n<p>final url <span class=\"token operator\">&#061;<\/span> currentUrl<span class=\"token punctuation\">;<\/span><br \/>\nfinal next <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">await<\/span> controller<span class=\"token operator\">!<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">getTitle<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token operator\">?.<\/span><span class=\"token function\">trim<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>mounted <span class=\"token operator\">&amp;&amp;<\/span> url <span class=\"token operator\">&#061;&#061;<\/span> currentUrl <span class=\"token operator\">&amp;&amp;<\/span> next <span class=\"token operator\">!&#061;<\/span> title<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>   <span class=\"token comment\">\/\/ \u2190 \u8bb0\u4e86 URL&#xff0c;\u56de\u6765\u6838\u5bf9<\/span><br \/>\n  <span class=\"token function\">setState<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> title <span class=\"token operator\">&#061;<\/span> next<span class=\"token operator\">?.<\/span>isNotEmpty <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token boolean\">true<\/span> <span class=\"token operator\">?<\/span> next <span class=\"token operator\">:<\/span> <span class=\"token keyword\">null<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>M4-09 \u7684 epoch \u68c0\u67e5\u3002<\/p>\n<p>\u56db\u5904\u770b\u8d77\u6765\u6beb\u4e0d\u76f8\u5e72\u7684\u4ee3\u7801&#xff0c;\u7528\u7684\u662f\u540c\u4e00\u4e2a\u6a21\u5f0f&#xff1a;\u53d1\u8d77\u65f6\u8bb0\u4e0b\u8eab\u4efd&#xff0c;\u56de\u6765\u65f6\u6838\u5bf9&#xff0c;\u4e0d\u5339\u914d\u5c31\u4e22\u5f03\u3002<\/p>\n<p>\u800c Flutter \u90a3\u8fb9\u8fd8\u6709\u4e24\u4e2a\u6761\u4ef6&#xff1a;<\/p>\n<table>\n<tr>\u6761\u4ef6\u9632\u4ec0\u4e48<\/tr>\n<tbody>\n<tr>\n<td>mounted<\/td>\n<td>Widget \u5df2\u7ecf\u9500\u6bc1 \u2192 setState \u4f1a\u629b\u5f02\u5e38<\/td>\n<\/tr>\n<tr>\n<td>ticket &#061;&#061; serial<\/td>\n<td>\u6709\u66f4\u65b0\u7684\u8bf7\u6c42\u5df2\u53d1\u51fa \u2192 \u65e7\u7ed3\u679c\u4e0d\u8be5\u8986\u76d6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>mounted \u90a3\u4e2a\u662f Flutter \u7279\u6709\u7684&#xff0c;\u56e0\u4e3a Widget \u751f\u547d\u5468\u671f\u662f\u6846\u67b6\u7ba1\u7406\u7684\u3002\u800c ticket\/epoch\/url \u90a3\u4e00\u5c42\u662f\u901a\u7528\u7684\u3002<\/p>\n<p>\u6240\u4ee5\u5982\u679c\u53ea\u770b\u8fd9\u4e2a\u6a21\u5f0f&#xff0c;\u4f60\u4f1a\u4ee5\u4e3a\u8fd9\u56db\u5904\u7684\u4ee3\u7801\u662f\u56db\u4e2a\u4e0d\u540c\u7684\u6280\u5de7\u3002\u5b9e\u9645\u4e0a\u5b83\u4eec\u662f\u540c\u4e00\u53e5\u8bdd&#xff1a;<\/p>\n<p>\u5f02\u6b65\u64cd\u4f5c\u7684\u7ed3\u679c&#xff0c;\u53ea\u5bf9\u53d1\u8d77\u5b83\u7684\u90a3\u4e2a\u4e16\u754c\u6709\u6548\u3002<\/p>\n<h3>\u5355\u98de&#xff1a;\u4e00\u4e2a\u7279\u4f8b<\/h3>\n<p>\u800c\u8fd9\u4e2a\u6a21\u5f0f\u6709\u4e00\u4e2a\u7279\u6b8a\u5f62\u6001&#xff0c;M4-09 \u8bb2\u8fc7&#xff0c;\u53eb&#034;\u5355\u98de&#034;&#xff1a;<\/p>\n<p>Future<span class=\"token operator\">&lt;<\/span><span class=\"token keyword\">void<\/span><span class=\"token operator\">&gt;<\/span> <span class=\"token function\">refresh<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>_refresh <span class=\"token operator\">!&#061;<\/span> <span class=\"token keyword\">null<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">return<\/span> _refresh<span class=\"token operator\">!<\/span><span class=\"token punctuation\">;<\/span>    <span class=\"token comment\">\/\/ \u2190 \u4e0d\u8bb0\u65b0\u8eab\u4efd&#xff0c;\u800c\u662f\u590d\u7528\u5df2\u6709\u7684<\/span><br \/>\n  <span class=\"token operator\">&#8230;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u4e3a\u4ec0\u4e48\u5237\u65b0\u8981\u590d\u7528\u800c\u4e0d\u662f\u5404\u5237\u5404\u7684&#xff1f;<\/p>\n<p>\u56e0\u4e3a\u5b83\u662f\u5207\u6362\u8bed\u4e49\u7684\u64cd\u4f5c&#xff08;\u7b2c\u4e00\u6b21\u5237\u6210\u529f&#xff0c;\u7b2c\u4e8c\u6b21\u5c31\u4f1a\u56e0 token \u5df2\u8f6e\u6362\u800c\u5931\u8d25&#xff09;\u3002\u800c\u4e94\u4e2a\u5e76\u53d1 401 \u4f1a\u89e6\u53d1\u4e94\u6b21\u5237\u65b0&#xff0c;\u800c\u8f6e\u6362\u8fc7\u7684 token \u7528\u4e00\u6b21\u5c31\u4f5c\u5e9f\u3002<\/p>\n<p>\u6240\u4ee5\u8fd9\u91cc\u7684\u5904\u7406\u4e0d\u662f&#034;\u8bb0\u8eab\u4efd\u7136\u540e\u4e22\u5f03\u65e7\u7684&#034;&#xff0c;\u800c\u662f&#034;\u540e\u6765\u7684\u76f4\u63a5\u7528\u524d\u4e00\u4e2a\u7684\u7ed3\u679c&#034;\u3002<\/p>\n<table>\n<tr>\u573a\u666f\u5904\u7406\u7406\u7531<\/tr>\n<tbody>\n<tr>\n<td>\u5217\u8868\u52a0\u8f7d<\/td>\n<td>\u8bb0 ticket&#xff0c;\u65e7\u7ed3\u679c\u4e22\u5f03<\/td>\n<td>\u591a\u4e2a\u8bf7\u6c42\u90fd\u5408\u6cd5&#xff0c;\u53ea\u8981\u6700\u65b0\u7684<\/td>\n<\/tr>\n<tr>\n<td>\u6807\u9898\u8f6e\u8be2<\/td>\n<td>\u8bb0 url&#xff0c;\u4e0d\u5339\u914d\u4e22\u5f03<\/td>\n<td>\u540c\u4e0a<\/td>\n<\/tr>\n<tr>\n<td>\u4ee4\u724c\u5237\u65b0<\/td>\n<td>\u590d\u7528 _refresh<\/td>\n<td>\u91cd\u590d\u6267\u884c\u4f1a\u5931\u8d25&#xff0c;\u5fc5\u987b\u5171\u4eab<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e2a\u533a\u522b\u5f88\u91cd\u8981&#xff1a;\u524d\u8005\u662f&#034;\u591a\u4e2a\u90fd\u53ef\u4ee5&#xff0c;\u53ea\u8981\u4e00\u4e2a\u7ed3\u679c&#034;&#xff0c;\u540e\u8005\u662f&#034;\u591a\u4e2a\u4f1a\u4e92\u76f8\u7834\u574f&#034;\u3002<\/p>\n<p>\u800c\u5224\u65ad\u6807\u51c6\u662f&#xff1a;\u91cd\u590d\u6267\u884c\u8fd9\u4e2a\u64cd\u4f5c&#xff0c;\u662f\u5426\u5b89\u5168&#xff1f;<\/p>\n<ul>\n<li>\u8bfb\u64cd\u4f5c \u2192 \u5b89\u5168&#xff08;\u8bb0\u8eab\u4efd\u5373\u53ef&#xff09;<\/li>\n<li>\u5207\u6362\u8bed\u4e49\u7684\u64cd\u4f5c \u2192 \u4e0d\u5b89\u5168&#xff08;\u5fc5\u987b\u5171\u4eab&#xff09;<\/li>\n<li>\u521b\u5efa\u64cd\u4f5c \u2192 \u4e0d\u5b89\u5168&#xff08;\u4f1a\u91cd\u590d\u521b\u5efa&#xff0c;M4-20 \u8bb2\u7684\u90a3\u4e2a&#xff09;<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261107140108-6aef2f24e3311.png\" alt=\"\u5e76\u53d1\u548c\u5e76\u884c\" \/><\/p>\n<h3>\u5e76\u884c\u4e0d\u662f\u5e76\u884c&#xff1a;async \u53ea\u662f&#034;\u4e0d\u963b\u585e&#034;<\/h3>\n<p>\u73b0\u5728\u8bb2\u4e00\u4e2a\u5e38\u89c1\u8bef\u89e3\u3002<\/p>\n<p><span class=\"token keyword\">const<\/span> <span class=\"token punctuation\">[<\/span>a<span class=\"token punctuation\">,<\/span> b<span class=\"token punctuation\">,<\/span> c<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> <span class=\"token builtin\">Promise<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">all<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">[<\/span><br \/>\n  <span class=\"token function\">fetchA<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token function\">fetchB<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token function\">fetchC<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u770b\u8d77\u6765\u662f\u4e09\u4e2a\u5e76\u884c&#xff0c;\u5b9e\u9645\u662f&#xff1a;\u4e09\u4e2a\u90fd\u53d1\u8d77 \u2192 \u7b49\u7b2c\u4e00\u4e2a\u5b8c\u6210 \u2192 \u7b49\u7b2c\u4e8c\u4e2a \u2192 \u7b49\u7b2c\u4e09\u4e2a\u3002<\/p>\n<p>\u800c&#034;\u4e09\u4e2a\u90fd\u53d1\u8d77&#034;\u624d\u662f\u5e76\u884c\u7684\u90e8\u5206\u2014\u2014\u5b83\u4eec\u51e0\u4e4e\u540c\u65f6\u628a\u8bf7\u6c42\u9001\u51fa\u53bb\u4e86\u3002\u800c Node \u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\u4e0d\u963b\u585e&#xff1a;<\/p>\n<ul>\n<li>\u53d1\u8d77 fetchA \u2192 \u8ba9\u51fa&#xff0c;\u53bb\u5904\u7406\u522b\u7684\u8fde\u63a5<\/li>\n<li>\u53d1\u8d77 fetchB \u2192 \u8ba9\u51fa<\/li>\n<li>\u53d1\u8d77 fetchC \u2192 \u8ba9\u51fa<\/li>\n<li>\u4e09\u8005\u7684\u54cd\u5e94\u9646\u7eed\u5230\u8fbe&#xff0c;\u56de\u8c03\u8fdb\u4e8b\u4ef6\u961f\u5217<\/li>\n<\/ul>\n<p>\u6240\u4ee5\u5b83\u662f&#034;\u5e76\u53d1 I\/O&#034;&#xff0c;\u4e0d\u662f&#034;\u5e76\u884c\u8ba1\u7b97&#034;\u3002<\/p>\n<table>\n<tr>\u5e76\u53d1 I\/O\u5e76\u884c\u8ba1\u7b97<\/tr>\n<tbody>\n<tr>\n<td>\u573a\u666f<\/td>\n<td>\u591a\u4e2a\u7f51\u7edc\u8bf7\u6c42<\/td>\n<td>CPU \u5bc6\u96c6\u8ba1\u7b97<\/td>\n<\/tr>\n<tr>\n<td>Node \u80fd\u529b<\/td>\n<td>\u2705 \u5355\u7ebf\u7a0b\u8db3\u591f<\/td>\n<td>\u274c \u9700\u8981 worker_threads<\/td>\n<\/tr>\n<tr>\n<td>\u74f6\u9888<\/td>\n<td>\u7f51\u7edc\u5ef6\u8fdf<\/td>\n<td>CPU \u6838\u6570<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u800c\u8fd9\u4e2a\u9879\u76ee\u91cc\u90a3\u4e2a&#034;\u767b\u5f55\u63a5\u53e3\u5f88\u6162&#034;\u7684\u95ee\u9898&#xff0c;\u6b63\u5c5e\u4e8e\u7b2c\u4e8c\u7c7b\u2014\u2014B-06 \u8bb2\u8fc7&#xff0c;\u6162\u5728 bcrypt \u7684 12 \u8f6e\u54c8\u5e0c&#xff0c;\u90a3\u662f\u7eaf CPU \u8ba1\u7b97\u3002<\/p>\n<p>\u5b83\u4e0d\u4f1a\u56e0\u4e3a\u6539\u6210 async \u800c\u53d8\u5feb\u3002 \u56e0\u4e3a async \u53ea\u89e3\u51b3&#034;\u7b49\u5f85&#034;\u95ee\u9898&#xff0c;\u4e0d\u89e3\u51b3&#034;\u8ba1\u7b97&#034;\u95ee\u9898\u3002<\/p>\n<h4>\u600e\u4e48\u5224\u65ad\u81ea\u5df1\u9047\u5230\u4e86\u54ea\u4e00\u79cd<\/h4>\n<p>\u4e00\u4e2a\u7b80\u5355\u7684\u533a\u5206\u65b9\u6cd5&#xff1a;\u628a\u8f93\u5165\u6362\u6210\u5e38\u91cf\u518d\u6d4b\u4e00\u6b21\u3002<\/p>\n<ul>\n<li>\u5982\u679c\u6162\u5728\u6570\u636e\u91cf \u2192 \u5927\u6982\u7387\u662f I\/O \u6216\u67e5\u8be2<\/li>\n<li>\u5982\u679c\u6162\u5728\u8ba1\u7b97 \u2192 \u5e38\u91cf\u8f93\u5165\u4e5f\u4f1a\u6162<\/li>\n<\/ul>\n<p>\u8fd9\u4e2a\u9879\u76ee\u91cc bcrypt \u5c31\u662f\u540e\u8005\u2014\u2014\u4f20 1 \u4e2a\u5b57\u7b26\u548c\u4f20 100 \u4e2a\u5b57\u7b26\u4e00\u6837\u6162&#xff0c;\u56e0\u4e3a\u8f6e\u6570\u56fa\u5b9a\u3002<\/p>\n<h3>\u540c\u6b65\u4ee3\u7801\u4f1a\u963b\u585e&#xff1a;\u6700\u5bb9\u6613\u72af\u7684\u9519<\/h3>\n<p>\u56de\u5230\u5f00\u5934\u90a3\u4e2a atomic&#xff1a;<\/p>\n<p><span class=\"token keyword\">return<\/span> client<span class=\"token punctuation\">.<\/span><span class=\"token function\">transaction<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span><br \/>\n  statements<span class=\"token punctuation\">.<\/span><span class=\"token function\">map<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>s<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> client<span class=\"token punctuation\">.<\/span><span class=\"token function\">prepare<\/span><span class=\"token punctuation\">(<\/span>s<span class=\"token punctuation\">.<\/span>sql<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">run<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&#8230;<\/span>s<span class=\"token punctuation\">.<\/span>params<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>changes<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd9\u4e00\u6bb5\u662f\u540c\u6b65\u7684\u2014\u2014transaction() \u7acb\u5373\u6267\u884c\u5b8c&#xff0c;\u8fd4\u56de\u6570\u7ec4&#xff0c;\u51fd\u6570\u7ed3\u675f\u3002<\/p>\n<p>\u800c\u8c03\u7528\u65b9\u770b\u5230\u7684\u662f\u4e00\u4e2a async \u51fd\u6570&#xff0c;\u6240\u4ee5\u5b83 await \u4e86\u4e00\u6b21&#xff1a;<\/p>\n<p><span class=\"token keyword\">const<\/span> changed <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> <span class=\"token function\">atomic<\/span><span class=\"token punctuation\">(<\/span>db<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token operator\">&#8230;<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u800c\u8fd9\u4e2a await \u5728\u672c\u5730\u8def\u5f84\u4e0a\u5b9e\u9645\u4e0a\u6ca1\u6709\u8ba9\u51fa\u2014\u2014\u56e0\u4e3a Promise \u5df2\u7ecf resolve \u4e86\u3002<\/p>\n<p>\u6240\u4ee5\u8fd9\u6bb5\u4ee3\u7801\u5728\u672c\u5730\u548c\u7ebf\u4e0a\u7684\u884c\u4e3a\u662f&#034;\u770b\u8d77\u6765\u4e00\u81f4&#034;\u7684&#xff1a;\u8c03\u7528\u65b9\u90fd await&#xff0c;\u90fd\u62ff\u5230 changes[]\u3002<\/p>\n<p>\u800c\u8fd9\u6b63\u662f\u5b83\u7684\u8bbe\u8ba1\u76ee\u7684&#xff08;M1-33 \u8bb2\u8fc7&#xff09;&#xff1a;\u4e1a\u52a1\u4ee3\u7801\u4e0d\u7528\u5173\u5fc3\u5f53\u524d\u662f\u54ea\u79cd\u8fd0\u884c\u65f6\u3002<\/p>\n<p>\u4f46\u8981\u6ce8\u610f\u4e00\u4e2a\u526f\u4f5c\u7528&#xff1a;\u5728\u672c\u5730\u8def\u5f84\u4e0a&#xff0c;\u8fd9\u4e2a await \u8ba9\u51fa\u4e00\u4e2a\u5fae\u4efb\u52a1\u3002\u5982\u679c\u8fd9\u6bb5\u4ee3\u7801\u5728\u4e00\u4e2a\u5faa\u73af\u91cc\u8c03\u4e00\u4e07\u6b21&#xff0c;\u5c31\u6709\u4e00\u4e07\u4e2a\u5fae\u4efb\u52a1\u3002 \u8fd9\u5728\u5b9e\u6d4b\u4e2d\u4e0d\u6784\u6210\u95ee\u9898&#xff08;\u56e0\u4e3a\u8fd9\u7c7b\u6279\u91cf\u64cd\u4f5c\u672c\u8eab\u5c31\u5f88\u91cd&#xff09;&#xff0c;\u4f46\u5b83\u8bf4\u660e&#034;\u52a0\u4e86 async \u4e0d\u7b49\u4e8e\u96f6\u6210\u672c&#034;\u3002<\/p>\n<p>\u66f4\u4e00\u822c\u7684\u6559\u8bad\u662f&#xff1a;\u628a\u540c\u6b65 API \u58f0\u660e\u6210 async&#xff0c;\u8c03\u7528\u65b9\u5c31\u4f1a\u88ab\u8feb await\u3002 \u800c await \u4e00\u4e2a\u5df2 resolve \u7684 Promise \u4f1a\u8ba9\u51fa\u5230\u5fae\u4efb\u52a1\u961f\u5217&#xff0c;\u6240\u4ee5\u5728\u70ed\u8def\u5f84\u4e0a\u8fd9\u662f\u6709\u6210\u672c\u7684\u3002<\/p>\n<p>\u6b63\u786e\u505a\u6cd5\u662f\u5206\u6210\u4e24\u4e2a\u51fd\u6570\u2014\u2014\u540c\u6b65\u7248\u548c\u5f02\u6b65\u7248&#xff0c;\u8ba9\u8c03\u7528\u65b9\u81ea\u5df1\u9009\u3002\u8fd9\u4e2a\u9879\u76ee\u6ca1\u505a&#xff0c;\u662f\u56e0\u4e3a\u8fd9\u4e2a\u8c03\u7528\u70b9\u4e0d\u5728\u70ed\u8def\u5f84\u4e0a\u3002\u4f46\u5b83\u662f\u4e00\u4e2a\u771f\u5b9e\u7684\u53d6\u820d&#xff0c;\u4e0d\u662f\u65e0\u6210\u672c\u7684\u4f18\u96c5\u3002<\/p>\n<h3>\u9519\u8bef\u5904\u7406\u5c5e\u4e8e\u5f02\u6b65\u6d41\u7a0b\u7684\u4e00\u90e8\u5206<\/h3>\n<p>\u6700\u540e\u8bb2\u8fd9\u5757&#xff0c;\u56e0\u4e3a\u5b83\u548c\u540c\u6b65\u4ee3\u7801\u7684\u4e60\u60ef\u4e0d\u540c\u3002<\/p>\n<p>\u540c\u6b65\u4ee3\u7801&#xff1a;<\/p>\n<p><span class=\"token keyword\">const<\/span> user <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">getUser<\/span><span class=\"token punctuation\">(<\/span>id<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ \u629b\u9519\u5c31\u629b\u9519<\/span><br \/>\n<span class=\"token function\">use<\/span><span class=\"token punctuation\">(<\/span>user<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u800c\u5f02\u6b65\u4ee3\u7801\u91cc&#xff0c;throw \u53d8\u6210&#034;reject \u4e00\u4e2a Promise&#034;&#xff0c;\u800c\u6ca1\u4eba await \u7684\u8bdd&#xff0c;\u5b83\u5c31\u53d8\u6210\u4e00\u4e2a unhandled rejection\u3002<\/p>\n<p>\u8fd9\u4e2a\u9879\u76ee\u91cc\u6709\u4e2a\u771f\u5b9e\u7684\u4f8b\u5b50&#xff1a;<\/p>\n<p><span class=\"token function\">unawaited<\/span><span class=\"token punctuation\">(<\/span><span class=\"token function\">_fetch<\/span><span class=\"token punctuation\">(<\/span>key<span class=\"token punctuation\">,<\/span> policy<span class=\"token punctuation\">,<\/span> fetch<span class=\"token punctuation\">,<\/span> tags<span class=\"token punctuation\">,<\/span> forbidden<span class=\"token punctuation\">)<\/span><br \/>\n  <span class=\"token punctuation\">.<\/span><span class=\"token function\">catchError<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>Object _<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token keyword\">null<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>unawaited() &#043; .catchError() \u2014\u2014\u4e24\u4e2a\u90fd\u662f\u523b\u610f\u7684\u3002<\/p>\n<ul>\n<li>unawaited()&#xff1a;\u544a\u8bc9 linter \u201c\u6211\u77e5\u9053\u6211\u6ca1 await&#xff0c;\u8fd9\u662f\u6545\u610f\u7684\u201d<\/li>\n<li>.catchError()&#xff1a;\u541e\u6389\u540e\u53f0\u4efb\u52a1\u7684\u9519\u8bef<\/li>\n<\/ul>\n<p>\u800c\u8fd9\u4e24\u8005\u7f3a\u4e00\u4e0d\u53ef&#xff1a;\u53ea\u5199 unawaited \u4f1a\u4ea7\u751f unhandled rejection&#xff08;Node \u4f1a\u6253\u5370\u8b66\u544a&#xff0c;\u67d0\u4e9b\u914d\u7f6e\u4e0b\u4f1a\u76f4\u63a5\u5d29\u6e83&#xff09;&#xff1b;\u53ea\u5199 catchError \u800c\u4e0d\u7528 unawaited&#xff0c;linter \u4f1a\u62a5&#034;\u672a\u5904\u7406\u7684 Promise&#034;\u3002<\/p>\n<p>\u8fd9\u4e2a\u5199\u6cd5\u628a&#034;\u6211\u77e5\u9053\u8fd9\u91cc\u6709\u4e2a Promise&#xff0c;\u6211\u6ca1\u7b49\u5b83&#034;\u8fd9\u4ef6\u4e8b\u663e\u5f0f\u5316\u4e86\u2014\u2014\u800c\u4e0d\u662f\u8ba9\u5b83\u770b\u8d77\u6765\u50cf\u5fd8\u4e86 await\u3002<\/p>\n<p>\u800c\u771f\u6b63\u9700\u8981 await \u7684\u5730\u65b9&#xff0c;\u9519\u8bef\u5c31\u6b63\u5e38\u5f80\u4e0a\u629b&#xff0c;\u7531\u9876\u5c42\u7684\u9519\u8bef\u5904\u7406\u6536\u53e3&#xff1a;<\/p>\n<p><span class=\"token keyword\">export<\/span> <span class=\"token keyword\">const<\/span> errorHandler<span class=\"token operator\">:<\/span> <span class=\"token function-variable function\">ErrorHandler<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span>err<span class=\"token punctuation\">,<\/span> _c<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>err <span class=\"token keyword\">instanceof<\/span> <span class=\"token class-name\">AppError<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token function\">failResponse<\/span><span class=\"token punctuation\">(<\/span>err<span class=\"token punctuation\">.<\/span>code<span class=\"token punctuation\">,<\/span> err<span class=\"token punctuation\">.<\/span>httpStatus<span class=\"token punctuation\">,<\/span> err<span class=\"token punctuation\">.<\/span>details<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n  <span class=\"token comment\">\/\/ \u515c\u5e95&#xff1a;\u672a\u77e5\u5f02\u5e38\u4e0d\u5e94\u5411\u5ba2\u6237\u7aef\u6cc4\u9732\u5806\u6808<\/span><br \/>\n  <span class=\"token builtin\">console<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">error<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;[unhandled]&#039;<\/span><span class=\"token punctuation\">,<\/span> err<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">return<\/span> <span class=\"token function\">failResponse<\/span><span class=\"token punctuation\">(<\/span>ErrCode<span class=\"token punctuation\">.<\/span><span class=\"token constant\">INTERNAL<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">500<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u6ce8\u610f\u90a3\u4e2a [unhandled] \u524d\u7f00\u2014\u2014\u5b83\u548c\u90a3\u4e9b\u88ab .catchError \u541e\u6389\u7684\u9519\u8bef\u5f62\u6210\u5bf9\u7167\u3002\u80fd\u5230\u8fd9\u91cc\u7684\u90fd\u662f&#034;\u6ca1\u4eba\u5904\u7406&#034;\u7684\u95ee\u9898&#xff0c;\u6240\u4ee5\u8981\u6253\u65e5\u5fd7\u3002<\/p>\n<h3>\u4e00\u6761\u6211\u4e00\u5f00\u59cb\u60f3\u7701\u6389\u7684\u4e8b<\/h3>\n<p>\u90a3\u4e2a&#034;\u8bb0\u8eab\u4efd\u3001\u56de\u6765\u6838\u5bf9&#034;\u7684\u6a21\u5f0f&#xff0c;\u6211\u6700\u521d\u7684\u5b9e\u73b0\u662f&#034;\u53ea\u68c0\u67e5 mounted&#034;\u3002<\/p>\n<p>\u7406\u7531\u662f&#034;Flutter \u91cc Widget \u9500\u6bc1\u4e86\u5c31\u4e0d\u8be5 setState&#xff0c;\u591f\u4e86&#034;\u3002<\/p>\n<p>\u7ed3\u679c\u662f\u4e00\u4e2a\u771f\u5b9e\u7684\u95ee\u9898&#xff1a;\u7528\u6237\u5728\u641c\u7d22\u9875\u5feb\u901f\u8f93\u5165&#xff0c;\u4e24\u6b21\u8bf7\u6c42\u51e0\u4e4e\u540c\u65f6\u53d1\u51fa&#xff0c;\u7b2c\u4e00\u4e2a\u8bf7\u6c42\u5148\u56de\u6765\u3002<\/p>\n<p>\u90a3\u65f6\u5019 mounted \u662f true&#xff08;\u9875\u9762\u8fd8\u5728&#xff09;&#xff0c;\u6240\u4ee5\u7b2c\u4e00\u4e2a\u7ed3\u679c\u76f4\u63a5\u6e32\u67d3\u4e86\u3002\u7136\u540e\u7b2c\u4e8c\u4e2a\u7ed3\u679c\u56de\u6765&#xff0c;\u8986\u76d6\u6389\u5b83\u3002<\/p>\n<p>\u7528\u6237\u770b\u5230\u7684\u662f&#xff1a;\u8f93\u5165&#034;a&#034;&#xff0c;\u770b\u5230\u7684\u7ed3\u679c\u5bf9\u5e94&#034;ab&#034;\u3002<\/p>\n<p>\u800c\u8fd9\u4e2a bug \u6781\u5176\u96be\u53d1\u73b0&#xff0c;\u56e0\u4e3a&#xff1a;\u5355\u6b21\u641c\u7d22\u5b8c\u5168\u6b63\u5e38\u3001\u7ed3\u679c\u901a\u5e38&#034;\u5dee\u4e0d\u591a\u5bf9&#034;\u3001\u800c\u4e24\u6b21\u8f93\u5165\u4e4b\u95f4\u7684\u95f4\u9694\u901a\u5e38\u53ea\u6709\u51e0\u767e\u6beb\u79d2\u3002<\/p>\n<p>\u52a0\u4e0a serial \u4e4b\u540e&#xff0c;\u8fd9\u7c7b\u95ee\u9898\u624d\u6d88\u5931\u3002 \u800c\u5b83\u7684\u6210\u672c\u53ea\u6709\u4e24\u884c\u3002<\/p>\n<p>\u800c\u8fd9\u4ef6\u4e8b\u548c Node \u90a3\u8fb9\u7684\u6559\u8bad\u662f\u540c\u4e00\u4e2a&#xff1a;\u5355\u7ebf\u7a0b\u4e0d\u4ee3\u8868\u903b\u8f91\u4e0d\u4f1a\u4ea4\u9519\u2014\u2014await \u5904\u5c31\u662f\u4ea4\u9519\u7684\u8fb9\u754c\u3002<\/p>\n<p>\u987a\u5e26\u8bf4 M4-10 \u90a3\u4e2a loadKey \u673a\u5236&#xff08;\u9632&#034;\u540c\u4e00\u4e2a Widget \u88ab\u590d\u7528\u4f46\u53c2\u6570\u53d8\u4e86&#034;&#xff09;\u4e5f\u662f\u540c\u4e00\u65cf\u7684\u95ee\u9898\u3002\u5b83\u7684\u8868\u73b0\u66f4\u9690\u853d&#xff1a;\u6587\u7ae0\u9875\u663e\u793a\u7684\u662f A \u4f5c\u8005\u7684\u6587\u7ae0&#xff0c;\u6807\u9898\u5374\u662f B \u7684\u2014\u2014\u56e0\u4e3a\u7ec4\u4ef6\u590d\u7528\u4e86&#xff0c;\u800c\u57fa\u7ebf\u503c\u6ca1\u91cd\u7f6e\u3002<\/p>\n<p>\u4e09\u4e2a\u95ee\u9898\u4e09\u4e2a\u73b0\u8c61&#xff0c;\u4e00\u4e2a\u6839\u56e0&#xff1a;\u5f02\u6b65\u7ed3\u679c\u88ab\u7528\u5728\u4e86\u5b83\u4e0d\u518d\u6210\u7acb\u7684\u4e0a\u4e0b\u6587\u91cc\u3002<\/p>\n<h3>\u5c0f\u7ed3<\/h3>\n<p>Node \u8fd0\u884c\u65f6\u5728\u8fd9\u4e2a\u9879\u76ee\u91cc\u6c89\u6dc0\u4e0b\u6765\u7684\u5224\u65ad&#xff1a;<\/p>\n<li>await \u4e0d\u53ea\u662f&#034;\u7b49&#034;&#xff0c;\u5b83\u662f&#034;\u4e16\u754c\u53ef\u80fd\u53d8\u4e86&#034;\u7684\u8fb9\u754c\u3002 \u6bcf\u6b21 await \u4e4b\u540e\u90fd\u8981\u91cd\u65b0\u786e\u8ba4\u524d\u7f6e\u5047\u8bbe\u3002<\/li>\n<li>\u5355\u7ebf\u7a0b\u4e0d\u7b49\u4e8e\u987a\u5e8f\u6267\u884c\u2014\u2014await \u4f1a\u8ba9\u51fa\u63a7\u5236\u6743&#xff0c;\u8ba9\u51fa\u671f\u95f4\u4f1a\u5904\u7406\u522b\u7684\u4e8b\u3002<\/li>\n<li>\u5e76\u53d1 I\/O \u2260 \u5e76\u884c\u8ba1\u7b97\u3002async \u89e3\u51b3\u7b49\u5f85&#xff0c;\u4e0d\u89e3\u51b3\u8ba1\u7b97\u3002<\/li>\n<li>\u540c\u6b65 API \u58f0\u660e\u6210 async \u6709\u6210\u672c&#xff08;\u5f3a\u5236\u8c03\u7528\u65b9 await \u591a\u4e00\u4e2a\u5fae\u4efb\u52a1&#xff09;&#xff0c;\u5c24\u5176\u5728\u70ed\u8def\u5f84\u4e0a\u3002<\/li>\n<li>\u540e\u53f0\u4efb\u52a1\u8981\u663e\u5f0f\u6807\u6ce8 unawaited &#043; catchError&#xff0c;\u5426\u5219\u8981\u4e48\u5d29\u6e83\u8981\u4e48\u88ab linter \u5ffd\u7565\u3002<\/li>\n<li>\u91cd\u590d\u6267\u884c\u662f\u5426\u5b89\u5168&#xff0c;\u51b3\u5b9a\u4e86\u5e76\u53d1\u5904\u7406\u65b9\u5f0f&#xff1a;\u5b89\u5168\u7684\u8bb0\u8eab\u4efd&#xff0c;\u4e0d\u5b89\u5168\u7684\u5fc5\u987b\u5171\u4eab&#xff08;\u5355\u98de&#xff09;\u3002<\/li>\n<p>\u800c\u7b2c 1 \u6761\u662f\u8fd9\u4e2a\u4e13\u680f\u8d2f\u7a7f\u591a\u4e2a\u7cfb\u5217\u7684\u6a21\u5f0f\u2014\u2014M4-09 \u7684 epoch\u3001M4-12 \u7684 serial\u3001M4-10 \u7684 ticket\u3001M4-15 \u7684 url \u6bd4\u8f83&#xff0c;\u56db\u4e2a\u5730\u65b9\u90fd\u662f\u540c\u4e00\u53e5\u8bdd\u7684\u4e0d\u540c\u63aa\u8f9e&#xff1a;<\/p>\n<p>\u5f02\u6b65\u7ed3\u679c\u53ea\u5bf9\u53d1\u8d77\u5b83\u7684\u90a3\u4e2a\u4e16\u754c\u6709\u6548\u3002<\/p>\n<p>\u800c Flutter \u90a3\u8fb9\u7684 mounted \u68c0\u67e5\u662f Node \u8fd9\u8fb9\u6ca1\u6709\u7684&#xff0c;\u56e0\u4e3a\u6846\u67b6\u4f1a\u9500\u6bc1 Widget&#xff0c;\u800c Node \u7684\u8bf7\u6c42\u6ca1\u6709&#034;\u88ab\u9500\u6bc1&#034;\u8fd9\u4e2a\u6982\u5ff5\u2014\u2014\u5b83\u7684&#034;\u4e0a\u4e0b\u6587\u6d88\u5931&#034;\u8868\u73b0\u4e3a\u7528\u6237\u767b\u51fa&#xff0c;\u800c\u90a3\u8981\u9760 epoch \u8fd9\u6837\u7684\u4e1a\u52a1\u6807\u8bb0\u624d\u80fd\u77e5\u9053\u3002<\/p>\n<p>\u8fd9\u8bf4\u660e\u540c\u4e00\u4e2a\u6a21\u5f0f\u5728\u4e0d\u540c\u73af\u5883\u91cc\u9700\u8981\u4e0d\u540c\u7684&#034;\u8eab\u4efd\u6807\u8bb0&#034;&#xff0c;\u800c\u6807\u8bb0\u7684\u6765\u6e90\u662f\u73af\u5883\u7279\u6709\u7684\u3002<\/p>\n<p>\u4e0b\u4e00\u7bc7\u8bb2\u670d\u52a1\u7aef\u7684\u5fc3\u667a\u6a21\u578b\u2014\u2014\u628a\u4e00\u4e2a\u8bf7\u6c42\u4ece\u6d4f\u89c8\u5668\u5230\u6570\u636e\u5e93\u7684\u5b8c\u6574\u94fe\u8def\u753b\u51fa\u6765&#xff0c;\u6807\u51fa\u6bcf\u4e00\u5c42\u53ef\u80fd\u5931\u8d25\u7684\u5730\u65b9\u3002<\/p>\n<h3>\u5ef6\u4f38\u9605\u8bfb<\/h3>\n<ul>\n<li>\u540e\u7aef\u5de5\u7a0b\u4ece\u96f6\u642d\u5efa&#xff1a;TypeScript\u3001\u76ee\u5f55\u4e0e\u70ed\u66f4\u65b0<\/li>\n<li>\u70b9\u8d5e\u7cfb\u7edf&#xff1a;\u5e42\u7b49\u70b9\u8d5e\u4e0e\u8ba1\u6570\u539f\u5b50\u589e\u51cf<\/li>\n<li>\u7ed3\u6784\u5316\u65e5\u5fd7\u4e0e\u8bf7\u6c42\u94fe\u8def\u8ffd\u8e2a<\/li>\n<\/ul>\n<hr \/>\n<p>\u5982\u679c\u8fd9\u7bc7\u6587\u7ae0\u5bf9\u4f60\u6709\u5e2e\u52a9&#xff0c;\u6b22\u8fce\u8ba2\u9605\u6211\u7684 CSDN \u4e13\u680f \u300c\u6210\u4e3a\u5168\u6808\u300d&#xff1a;<\/p>\n<p>&#x1f517; \u4e13\u680f\u5730\u5740&#xff1a;https:\/\/blog.csdn.net\/fungleo\/category_13204651.html<\/p>\n<p>&#x1f4e6; \u672c\u7cfb\u5217\u914d\u5957\u4ee3\u7801\u4ed3\u5e93&#xff1a;https:\/\/github.com\/fengcms\/become-a-full-stack-developer<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261107140109-6aef2f25c4ec1.png\" alt=\"\u6210\u4e3a\u5168\u6808\u4e13\u680f\u8ba2\u9605\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6210\u4e3a\u5168\u6808\u00b7\u57fa\u7840\u8865\u5145\u00b7Node.js \u8fd0\u884c\u65f6&#xff1a;\u4e8b\u4ef6\u5faa\u73af\u4e0e\u5f02\u6b65<br \/>\n\u8fd9\u4e2a\u9879\u76ee\u91cc\u6709\u4e00\u6bb5\u4ee3\u7801&#xff0c;\u5b83\u7684\u5916\u5f62\u662f async&#xff0c;\u4f46\u5185\u90e8\u8c03\u7528\u7684\u662f\u4e00\u4e2a\u540c\u6b65\u51fd\u6570&#xff1a;<br \/>\n\/** \u540c\u4e00\u6279 SQL \u5728 SQLite \u4e8b\u52a1\u6216 D1 batch \u4e2d\u6267\u884c&#xff1b;\u5f02\u5e38\u6574\u4f53\u56de\u6eda\u3002 *\/<br \/>\nexport async function atomic(db: Db, statements: Statement[]): Promise {cons<\/p>\n","protected":false},"author":2,"featured_media":123621,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[14172,11686,187,186,3514],"topic":[],"class_list":["post-123625","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-14172","tag-11686","tag-javascript","tag-node-js","tag-3514"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u6210\u4e3a\u5168\u6808\u00b7\u57fa\u7840\u8865\u5145\u00b7Node.js \u8fd0\u884c\u65f6\uff1a\u4e8b\u4ef6\u5faa\u73af\u4e0e\u5f02\u6b65 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/123625.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u6210\u4e3a\u5168\u6808\u00b7\u57fa\u7840\u8865\u5145\u00b7Node.js \u8fd0\u884c\u65f6\uff1a\u4e8b\u4ef6\u5faa\u73af\u4e0e\u5f02\u6b65 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6210\u4e3a\u5168\u6808\u00b7\u57fa\u7840\u8865\u5145\u00b7Node.js \u8fd0\u884c\u65f6&#xff1a;\u4e8b\u4ef6\u5faa\u73af\u4e0e\u5f02\u6b65 \u8fd9\u4e2a\u9879\u76ee\u91cc\u6709\u4e00\u6bb5\u4ee3\u7801&#xff0c;\u5b83\u7684\u5916\u5f62\u662f async&#xff0c;\u4f46\u5185\u90e8\u8c03\u7528\u7684\u662f\u4e00\u4e2a\u540c\u6b65\u51fd\u6570&#xff1a; \/** \u540c\u4e00\u6279 SQL \u5728 SQLite \u4e8b\u52a1\u6216 D1 batch \u4e2d\u6267\u884c&#xff1b;\u5f02\u5e38\u6574\u4f53\u56de\u6eda\u3002 *\/ export async function atomic(db: Db, statements: Statement[]): Promise {cons\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/123625.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-07T14:01:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261107140107-6aef2f23063da.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/123625.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/123625.html\",\"name\":\"\u6210\u4e3a\u5168\u6808\u00b7\u57fa\u7840\u8865\u5145\u00b7Node.js \u8fd0\u884c\u65f6\uff1a\u4e8b\u4ef6\u5faa\u73af\u4e0e\u5f02\u6b65 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-07T14:01:12+00:00\",\"dateModified\":\"2026-11-07T14:01:12+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/123625.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/123625.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/123625.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u6210\u4e3a\u5168\u6808\u00b7\u57fa\u7840\u8865\u5145\u00b7Node.js \u8fd0\u884c\u65f6\uff1a\u4e8b\u4ef6\u5faa\u73af\u4e0e\u5f02\u6b65\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u6210\u4e3a\u5168\u6808\u00b7\u57fa\u7840\u8865\u5145\u00b7Node.js \u8fd0\u884c\u65f6\uff1a\u4e8b\u4ef6\u5faa\u73af\u4e0e\u5f02\u6b65 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/123625.html","og_locale":"zh_CN","og_type":"article","og_title":"\u6210\u4e3a\u5168\u6808\u00b7\u57fa\u7840\u8865\u5145\u00b7Node.js \u8fd0\u884c\u65f6\uff1a\u4e8b\u4ef6\u5faa\u73af\u4e0e\u5f02\u6b65 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6210\u4e3a\u5168\u6808\u00b7\u57fa\u7840\u8865\u5145\u00b7Node.js \u8fd0\u884c\u65f6&#xff1a;\u4e8b\u4ef6\u5faa\u73af\u4e0e\u5f02\u6b65 \u8fd9\u4e2a\u9879\u76ee\u91cc\u6709\u4e00\u6bb5\u4ee3\u7801&#xff0c;\u5b83\u7684\u5916\u5f62\u662f async&#xff0c;\u4f46\u5185\u90e8\u8c03\u7528\u7684\u662f\u4e00\u4e2a\u540c\u6b65\u51fd\u6570&#xff1a; \/** \u540c\u4e00\u6279 SQL \u5728 SQLite \u4e8b\u52a1\u6216 D1 batch \u4e2d\u6267\u884c&#xff1b;\u5f02\u5e38\u6574\u4f53\u56de\u6eda\u3002 *\/ export async function atomic(db: Db, statements: Statement[]): Promise {cons","og_url":"https:\/\/www.wsisp.com\/helps\/123625.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-07T14:01:12+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261107140107-6aef2f23063da.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/123625.html","url":"https:\/\/www.wsisp.com\/helps\/123625.html","name":"\u6210\u4e3a\u5168\u6808\u00b7\u57fa\u7840\u8865\u5145\u00b7Node.js \u8fd0\u884c\u65f6\uff1a\u4e8b\u4ef6\u5faa\u73af\u4e0e\u5f02\u6b65 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-07T14:01:12+00:00","dateModified":"2026-11-07T14:01:12+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/123625.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/123625.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/123625.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u6210\u4e3a\u5168\u6808\u00b7\u57fa\u7840\u8865\u5145\u00b7Node.js \u8fd0\u884c\u65f6\uff1a\u4e8b\u4ef6\u5faa\u73af\u4e0e\u5f02\u6b65"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/123625","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=123625"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/123625\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/123621"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=123625"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=123625"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=123625"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=123625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}