From 322949e8e1c91cb4b40701d32cee282572a506e3 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 13 Dec 2024 22:01:14 +0800 Subject: [PATCH] :art: Add SQL query template function `querySQL` https://github.com/siyuan-note/siyuan/issues/13455 --- .../20201204184532-3qm9l8n.sy | 533 +++++++++-------- .../20201204181006-7bkppue.sy | 551 ++++++++++-------- .../20211226123004-dplpw0o.sy | 533 +++++++++-------- .../20240530101000-6x9ivi7.sy | 540 +++++++++-------- kernel/sql/database.go | 4 + 5 files changed, 1149 insertions(+), 1012 deletions(-) diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201204184532-3qm9l8n.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201204184532-3qm9l8n.sy index a94b5d623..1a371f142 100644 --- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201204184532-3qm9l8n.sy +++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201204184532-3qm9l8n.sy @@ -6,7 +6,7 @@ "id": "20201204184532-3qm9l8n", "title": "Template snippet", "type": "doc", - "updated": "20241212163918" + "updated": "20241213215714" }, "Children": [ { @@ -57,7 +57,7 @@ "HeadingLevel": 2, "Properties": { "id": "20210104091444-jy56z0p", - "updated": "20241212163918" + "updated": "20241213215714" }, "Children": [ { @@ -215,7 +215,7 @@ "ListData": {}, "Properties": { "id": "20210104091444-mwbvc9m", - "updated": "20241212163918" + "updated": "20241213215714" }, "Children": [ { @@ -429,7 +429,7 @@ "Type": "NodeParagraph", "Properties": { "id": "20210131162138-7ufhbho", - "updated": "20240403150956" + "updated": "20241213215545" }, "Children": [ { @@ -443,7 +443,33 @@ }, { "Type": "NodeText", - "Data": "​: This function is used to query the database, and the return value is a list of blocks, please refer to the example below" + "Data": "​: This function is used to query the database, and the return value is a list of blocks" + } + ] + }, + { + "ID": "20241213215602-dk7iion", + "Type": "NodeCodeBlock", + "IsFencedCodeBlock": true, + "Properties": { + "id": "20241213215602-dk7iion", + "updated": "20241213215602" + }, + "Children": [ + { + "Type": "NodeCodeBlockFenceOpenMarker", + "Data": "```" + }, + { + "Type": "NodeCodeBlockFenceInfoMarker" + }, + { + "Type": "NodeCodeBlockCode", + "Data": ".action{$today := now | date \"20060102150405\"}\n.action{$blocks :=queryBlocks \"SELECT * FROM blocks WHERE content LIKE '?' AND updated \u003e '?' LIMIT ?\" \"%foo%\" $today \"3\"}\n" + }, + { + "Type": "NodeCodeBlockFenceCloseMarker", + "Data": "```" } ] } @@ -466,7 +492,7 @@ "Type": "NodeParagraph", "Properties": { "id": "20210504093232-6wxl589", - "updated": "20240403151002" + "updated": "20241213215547" }, "Children": [ { @@ -480,7 +506,96 @@ }, { "Type": "NodeText", - "Data": "​: This function is used to query the database, and the return value is a list of spans, please refer to the example below" + "Data": "​: This function is used to query the database, and the return value is a list of spans" + } + ] + }, + { + "ID": "20241213215606-a1mq6zf", + "Type": "NodeCodeBlock", + "IsFencedCodeBlock": true, + "Properties": { + "id": "20241213215606-a1mq6zf", + "updated": "20241213215606" + }, + "Children": [ + { + "Type": "NodeCodeBlockFenceOpenMarker", + "Data": "```" + }, + { + "Type": "NodeCodeBlockFenceInfoMarker" + }, + { + "Type": "NodeCodeBlockCode", + "Data": " .action{querySQL \"SELECT * FROM spans LIMIT ?\" \"3\"}\n" + }, + { + "Type": "NodeCodeBlockFenceCloseMarker", + "Data": "```" + } + ] + } + ] + }, + { + "ID": "20241213214939-he4wmcd", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241213214939-he4wmcd", + "updated": "20241213214939" + }, + "Children": [ + { + "ID": "20241213214939-hrshqgv", + "Type": "NodeParagraph", + "Properties": { + "id": "20241213214939-hrshqgv", + "updated": "20241213215550" + }, + "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, + { + "Type": "NodeTextMark", + "TextMarkType": "code", + "TextMarkTextContent": "querySQL" + }, + { + "Type": "NodeText", + "Data": "​: This function is used to query the database and the return value is a result set" + } + ] + }, + { + "ID": "20241213215554-rox3jk7", + "Type": "NodeCodeBlock", + "IsFencedCodeBlock": true, + "Properties": { + "id": "20241213215554-rox3jk7", + "updated": "20241213215554" + }, + "Children": [ + { + "Type": "NodeCodeBlockFenceOpenMarker", + "Data": "```" + }, + { + "Type": "NodeCodeBlockFenceInfoMarker" + }, + { + "Type": "NodeCodeBlockCode", + "Data": " .action{querySQL \"SELECT * FROM refs LIMIT 3\"}\n" + }, + { + "Type": "NodeCodeBlockFenceCloseMarker", + "Data": "```" } ] } @@ -495,7 +610,7 @@ }, "Properties": { "id": "20241212102027-j293sei", - "updated": "20241212163902" + "updated": "20241213215714" }, "Children": [ { @@ -522,225 +637,203 @@ ] }, { - "ID": "20241212102028-60g8ajq", + "ID": "20241213215714-u0j3i4k", + "Type": "NodeCodeBlock", + "IsFencedCodeBlock": true, + "Properties": { + "id": "20241213215714-u0j3i4k", + "updated": "20241213215714" + }, + "Children": [ + { + "Type": "NodeCodeBlockFenceOpenMarker", + "Data": "```" + }, + { + "Type": "NodeCodeBlockFenceInfoMarker" + }, + { + "Type": "NodeCodeBlockCode", + "Data": ".action{ (statBlock .id).RuneCount} .action{ (statBlock .id).WordCount}\n" + }, + { + "Type": "NodeCodeBlockFenceCloseMarker", + "Data": "```" + } + ] + }, + { + "ID": "20241212102028-4ew89te", "Type": "NodeList", "ListData": {}, "Properties": { - "id": "20241212102028-60g8ajq", + "id": "20241212102028-4ew89te", "updated": "20241212102028" }, "Children": [ { - "ID": "20241212102028-eiulm47", + "ID": "20241212102028-wai3afs", "Type": "NodeListItem", "ListData": { "BulletChar": 42, "Marker": "Kg==" }, "Properties": { - "id": "20241212102028-eiulm47", + "id": "20241212102028-wai3afs", "updated": "20241212102028" }, "Children": [ { - "ID": "20241212102028-ac9h87f", + "ID": "20241212102028-wmtwngj", "Type": "NodeParagraph", "Properties": { - "id": "20241212102028-ac9h87f", + "id": "20241212102028-wmtwngj", "updated": "20241212102028" }, "Children": [ { "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": ".action{ (statBlock .id).RuneCount} .action{ (statBlock .id).WordCount}" - }, - { - "Type": "NodeText", - "Data": "​" + "Data": "RuneCount" } ] - }, + } + ] + }, + { + "ID": "20241212102028-r9k7ody", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212102028-r9k7ody", + "updated": "20241212102028" + }, + "Children": [ { - "ID": "20241212102028-4ew89te", - "Type": "NodeList", - "ListData": {}, + "ID": "20241212102028-le5lpgo", + "Type": "NodeParagraph", "Properties": { - "id": "20241212102028-4ew89te", + "id": "20241212102028-le5lpgo", "updated": "20241212102028" }, "Children": [ { - "ID": "20241212102028-wai3afs", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212102028-wai3afs", - "updated": "20241212102028" - }, - "Children": [ - { - "ID": "20241212102028-wmtwngj", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212102028-wmtwngj", - "updated": "20241212102028" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "RuneCount" - } - ] - } - ] - }, + "Type": "NodeText", + "Data": "WordCount" + } + ] + } + ] + }, + { + "ID": "20241212102028-3egh1dg", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212102028-3egh1dg", + "updated": "20241212102028" + }, + "Children": [ + { + "ID": "20241212102028-pijmoea", + "Type": "NodeParagraph", + "Properties": { + "id": "20241212102028-pijmoea", + "updated": "20241212102028" + }, + "Children": [ { - "ID": "20241212102028-r9k7ody", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212102028-r9k7ody", - "updated": "20241212102028" - }, - "Children": [ - { - "ID": "20241212102028-le5lpgo", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212102028-le5lpgo", - "updated": "20241212102028" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "WordCount" - } - ] - } - ] - }, + "Type": "NodeText", + "Data": "LinkCount" + } + ] + } + ] + }, + { + "ID": "20241212102028-qu6f5tc", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212102028-qu6f5tc", + "updated": "20241212102028" + }, + "Children": [ + { + "ID": "20241212102028-8yj65um", + "Type": "NodeParagraph", + "Properties": { + "id": "20241212102028-8yj65um", + "updated": "20241212102028" + }, + "Children": [ { - "ID": "20241212102028-3egh1dg", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212102028-3egh1dg", - "updated": "20241212102028" - }, - "Children": [ - { - "ID": "20241212102028-pijmoea", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212102028-pijmoea", - "updated": "20241212102028" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "LinkCount" - } - ] - } - ] - }, + "Type": "NodeText", + "Data": "ImageCount" + } + ] + } + ] + }, + { + "ID": "20241212102028-8ivthzb", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212102028-8ivthzb", + "updated": "20241212102028" + }, + "Children": [ + { + "ID": "20241212102028-p8nmm3a", + "Type": "NodeParagraph", + "Properties": { + "id": "20241212102028-p8nmm3a", + "updated": "20241212102028" + }, + "Children": [ { - "ID": "20241212102028-qu6f5tc", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212102028-qu6f5tc", - "updated": "20241212102028" - }, - "Children": [ - { - "ID": "20241212102028-8yj65um", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212102028-8yj65um", - "updated": "20241212102028" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "ImageCount" - } - ] - } - ] - }, + "Type": "NodeText", + "Data": "RefCount" + } + ] + } + ] + }, + { + "ID": "20241212102028-frusted", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212102028-frusted", + "updated": "20241212102028" + }, + "Children": [ + { + "ID": "20241212102028-h58utua", + "Type": "NodeParagraph", + "Properties": { + "id": "20241212102028-h58utua", + "updated": "20241212102028" + }, + "Children": [ { - "ID": "20241212102028-8ivthzb", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212102028-8ivthzb", - "updated": "20241212102028" - }, - "Children": [ - { - "ID": "20241212102028-p8nmm3a", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212102028-p8nmm3a", - "updated": "20241212102028" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "RefCount" - } - ] - } - ] - }, - { - "ID": "20241212102028-frusted", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212102028-frusted", - "updated": "20241212102028" - }, - "Children": [ - { - "ID": "20241212102028-h58utua", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212102028-h58utua", - "updated": "20241212102028" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "BlockCount" - } - ] - } - ] + "Type": "NodeText", + "Data": "BlockCount" } ] } @@ -1158,64 +1251,6 @@ } ] }, - { - "ID": "20210604111714-yc1e5gj", - "Type": "NodeParagraph", - "Properties": { - "id": "20210604111714-yc1e5gj", - "updated": "20210604111715" - }, - "Children": [ - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "queryBlocks" - }, - { - "Type": "NodeText", - "Data": " and " - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "querySpans" - }, - { - "Type": "NodeText", - "Data": " support variable parameter lists similar to SQL prepared statements to facilitate the input of parameters:" - } - ] - }, - { - "ID": "20210604111750-c3sm3jr", - "Type": "NodeCodeBlock", - "IsFencedCodeBlock": true, - "Properties": { - "id": "20210604111750-c3sm3jr", - "updated": "20210604111632" - }, - "Children": [ - { - "Type": "NodeCodeBlockFenceOpenMarker", - "Data": "```" - }, - { - "Type": "NodeCodeBlockFenceInfoMarker" - }, - { - "ID": "20220307092214-3yza25q", - "Type": "NodeCodeBlockCode", - "Data": ".action{$today := now | date \"20060102150405\"}\n.action{$blocks :=queryBlocks \"SELECT * FROM blocks WHERE content LIKE '?' AND updated \u003e '?' LIMIT ?\" \"%foo%\" $today \"3\"}\n", - "Properties": { - "id": "20220307092214-3yza25q" - } - }, - { - "Type": "NodeCodeBlockFenceCloseMarker", - "Data": "```" - } - ] - }, { "ID": "20210104091444-4re70bp", "Type": "NodeHeading", diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201204181006-7bkppue.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201204181006-7bkppue.sy index a5ea9dbea..2e5b833df 100644 --- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201204181006-7bkppue.sy +++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201204181006-7bkppue.sy @@ -6,7 +6,7 @@ "id": "20201204181006-7bkppue", "title": "模板片段", "type": "doc", - "updated": "20241212163739" + "updated": "20241213215655" }, "Children": [ { @@ -69,7 +69,7 @@ "HeadingLevel": 2, "Properties": { "id": "20210104091309-fhb549c", - "updated": "20241212163739" + "updated": "20241213215655" }, "Children": [ { @@ -237,7 +237,7 @@ "ListData": {}, "Properties": { "id": "20210104091309-gjkg3u5", - "updated": "20241212163739" + "updated": "20241213215655" }, "Children": [ { @@ -451,7 +451,7 @@ "Type": "NodeParagraph", "Properties": { "id": "20210131155558-ghlchbx", - "updated": "20240403150712" + "updated": "20241213215236" }, "Children": [ { @@ -465,7 +465,33 @@ }, { "Type": "NodeText", - "Data": "​:该函数用于查询数据库,返回值为 blocks 列表,请参考下面的例子" + "Data": "​:该函数用于查询数据库,返回值为 blocks 列表" + } + ] + }, + { + "ID": "20210604111446-p6vadfc", + "Type": "NodeCodeBlock", + "IsFencedCodeBlock": true, + "Properties": { + "id": "20210604111446-p6vadfc", + "updated": "20241213215118" + }, + "Children": [ + { + "Type": "NodeCodeBlockFenceOpenMarker", + "Data": "```" + }, + { + "Type": "NodeCodeBlockFenceInfoMarker" + }, + { + "Type": "NodeCodeBlockCode", + "Data": ".action{$today := now | date \"20060102150405\"}\n.action{$blocks :=queryBlocks \"SELECT * FROM blocks WHERE content LIKE '?' AND updated \u003e '?' LIMIT ?\" \"%foo%\" $today \"3\"}\n" + }, + { + "Type": "NodeCodeBlockFenceCloseMarker", + "Data": "```" } ] } @@ -480,7 +506,7 @@ }, "Properties": { "id": "20210504093313-4aoyxd0", - "updated": "20240403150838" + "updated": "20241213215416" }, "Children": [ { @@ -488,7 +514,7 @@ "Type": "NodeParagraph", "Properties": { "id": "20210504093313-ya53o58", - "updated": "20240403150838" + "updated": "20241213215302" }, "Children": [ { @@ -502,7 +528,96 @@ }, { "Type": "NodeText", - "Data": "​:该函数用于查询数据库,返回值为 spans 列表,请参考下面的例子" + "Data": "​:该函数用于查询数据库,返回值为 spans 列表" + } + ] + }, + { + "ID": "20241213215337-rhkoc8k", + "Type": "NodeCodeBlock", + "IsFencedCodeBlock": true, + "Properties": { + "id": "20241213215337-rhkoc8k", + "updated": "20241213215416" + }, + "Children": [ + { + "Type": "NodeCodeBlockFenceOpenMarker", + "Data": "```" + }, + { + "Type": "NodeCodeBlockFenceInfoMarker" + }, + { + "Type": "NodeCodeBlockCode", + "Data": " .action{querySQL \"SELECT * FROM spans LIMIT ?\" \"3\"}\n" + }, + { + "Type": "NodeCodeBlockFenceCloseMarker", + "Data": "```" + } + ] + } + ] + }, + { + "ID": "20241213214733-ro4xcjm", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241213214733-ro4xcjm", + "updated": "20241213215421" + }, + "Children": [ + { + "ID": "20241213214733-73dpip9", + "Type": "NodeParagraph", + "Properties": { + "id": "20241213214733-73dpip9", + "updated": "20241213215139" + }, + "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, + { + "Type": "NodeTextMark", + "TextMarkType": "code", + "TextMarkTextContent": "querySQL" + }, + { + "Type": "NodeText", + "Data": "​:该函数用于查询数据库,返回值为结果集" + } + ] + }, + { + "ID": "20241213215240-f33bsqs", + "Type": "NodeCodeBlock", + "IsFencedCodeBlock": true, + "Properties": { + "id": "20241213215240-f33bsqs", + "updated": "20241213215421" + }, + "Children": [ + { + "Type": "NodeCodeBlockFenceOpenMarker", + "Data": "```" + }, + { + "Type": "NodeCodeBlockFenceInfoMarker" + }, + { + "Type": "NodeCodeBlockCode", + "Data": " .action{querySQL \"SELECT * FROM refs LIMIT 3\"}\n" + }, + { + "Type": "NodeCodeBlockFenceCloseMarker", + "Data": "```" } ] } @@ -517,7 +632,7 @@ }, "Properties": { "id": "20241212101708-0euo6is", - "updated": "20241212163723" + "updated": "20241213215655" }, "Children": [ { @@ -544,225 +659,203 @@ ] }, { - "ID": "20241212101812-xivegzi", + "ID": "20241212101810-6ffociu", + "Type": "NodeCodeBlock", + "IsFencedCodeBlock": true, + "Properties": { + "id": "20241212101810-6ffociu", + "updated": "20241213215655" + }, + "Children": [ + { + "Type": "NodeCodeBlockFenceOpenMarker", + "Data": "```" + }, + { + "Type": "NodeCodeBlockFenceInfoMarker" + }, + { + "Type": "NodeCodeBlockCode", + "Data": ".action{ (statBlock .id).RuneCount} .action{ (statBlock .id).WordCount}\n" + }, + { + "Type": "NodeCodeBlockFenceCloseMarker", + "Data": "```" + } + ] + }, + { + "ID": "20241212101821-kf6un09", "Type": "NodeList", "ListData": {}, "Properties": { - "id": "20241212101812-xivegzi", + "id": "20241212101821-kf6un09", "updated": "20241212101821" }, "Children": [ { - "ID": "20241212101810-d297xu2", + "ID": "20241212101821-1qt2j1i", "Type": "NodeListItem", "ListData": { "BulletChar": 42, "Marker": "Kg==" }, "Properties": { - "id": "20241212101810-d297xu2", + "id": "20241212101821-1qt2j1i", "updated": "20241212101821" }, "Children": [ { - "ID": "20241212101810-6ffociu", + "ID": "20241212101821-mkxql2a", "Type": "NodeParagraph", "Properties": { - "id": "20241212101810-6ffociu", - "updated": "20241212101812" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": ".action{ (statBlock .id).RuneCount} .action{ (statBlock .id).WordCount}" - }, - { - "Type": "NodeText", - "Data": "​" - } - ] - }, - { - "ID": "20241212101821-kf6un09", - "Type": "NodeList", - "ListData": {}, - "Properties": { - "id": "20241212101821-kf6un09", + "id": "20241212101821-mkxql2a", "updated": "20241212101821" }, "Children": [ { - "ID": "20241212101821-1qt2j1i", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212101821-1qt2j1i", - "updated": "20241212101821" - }, - "Children": [ - { - "ID": "20241212101821-mkxql2a", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212101821-mkxql2a", - "updated": "20241212101821" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "RuneCount" - } - ] - } - ] - }, + "Type": "NodeText", + "Data": "RuneCount" + } + ] + } + ] + }, + { + "ID": "20241212101821-kok8u5t", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212101821-kok8u5t", + "updated": "20241212101821" + }, + "Children": [ + { + "ID": "20241212101821-7gsgfqo", + "Type": "NodeParagraph", + "Properties": { + "id": "20241212101821-7gsgfqo", + "updated": "20241212101821" + }, + "Children": [ { - "ID": "20241212101821-kok8u5t", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212101821-kok8u5t", - "updated": "20241212101821" - }, - "Children": [ - { - "ID": "20241212101821-7gsgfqo", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212101821-7gsgfqo", - "updated": "20241212101821" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "WordCount" - } - ] - } - ] - }, + "Type": "NodeText", + "Data": "WordCount" + } + ] + } + ] + }, + { + "ID": "20241212101821-jxbirdz", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212101821-jxbirdz", + "updated": "20241212101821" + }, + "Children": [ + { + "ID": "20241212101821-mep8mwc", + "Type": "NodeParagraph", + "Properties": { + "id": "20241212101821-mep8mwc", + "updated": "20241212101821" + }, + "Children": [ { - "ID": "20241212101821-jxbirdz", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212101821-jxbirdz", - "updated": "20241212101821" - }, - "Children": [ - { - "ID": "20241212101821-mep8mwc", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212101821-mep8mwc", - "updated": "20241212101821" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "LinkCount" - } - ] - } - ] - }, + "Type": "NodeText", + "Data": "LinkCount" + } + ] + } + ] + }, + { + "ID": "20241212101821-8dho5yg", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212101821-8dho5yg", + "updated": "20241212101821" + }, + "Children": [ + { + "ID": "20241212101821-hriiyll", + "Type": "NodeParagraph", + "Properties": { + "id": "20241212101821-hriiyll", + "updated": "20241212101821" + }, + "Children": [ { - "ID": "20241212101821-8dho5yg", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212101821-8dho5yg", - "updated": "20241212101821" - }, - "Children": [ - { - "ID": "20241212101821-hriiyll", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212101821-hriiyll", - "updated": "20241212101821" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "ImageCount" - } - ] - } - ] - }, + "Type": "NodeText", + "Data": "ImageCount" + } + ] + } + ] + }, + { + "ID": "20241212101821-mrg92au", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212101821-mrg92au", + "updated": "20241212101821" + }, + "Children": [ + { + "ID": "20241212101821-ovwsmzs", + "Type": "NodeParagraph", + "Properties": { + "id": "20241212101821-ovwsmzs", + "updated": "20241212101821" + }, + "Children": [ { - "ID": "20241212101821-mrg92au", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212101821-mrg92au", - "updated": "20241212101821" - }, - "Children": [ - { - "ID": "20241212101821-ovwsmzs", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212101821-ovwsmzs", - "updated": "20241212101821" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "RefCount" - } - ] - } - ] - }, + "Type": "NodeText", + "Data": "RefCount" + } + ] + } + ] + }, + { + "ID": "20241212101821-kq0fb53", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212101821-kq0fb53", + "updated": "20241212101821" + }, + "Children": [ + { + "ID": "20241212101821-6k4evcn", + "Type": "NodeParagraph", + "Properties": { + "id": "20241212101821-6k4evcn", + "updated": "20241212101821" + }, + "Children": [ { - "ID": "20241212101821-kq0fb53", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212101821-kq0fb53", - "updated": "20241212101821" - }, - "Children": [ - { - "ID": "20241212101821-6k4evcn", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212101821-6k4evcn", - "updated": "20241212101821" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "BlockCount" - } - ] - } - ] + "Type": "NodeText", + "Data": "BlockCount" } ] } @@ -1180,64 +1273,6 @@ } ] }, - { - "ID": "20210604111213-774ll6c", - "Type": "NodeParagraph", - "Properties": { - "id": "20210604111213-774ll6c", - "updated": "20210604111557" - }, - "Children": [ - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "queryBlocks" - }, - { - "Type": "NodeText", - "Data": " 和 " - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "querySpans" - }, - { - "Type": "NodeText", - "Data": " 支持类似 SQL 预编译语句的变参列表,方便传入参数:" - } - ] - }, - { - "ID": "20210604111446-p6vadfc", - "Type": "NodeCodeBlock", - "IsFencedCodeBlock": true, - "Properties": { - "id": "20210604111446-p6vadfc", - "updated": "20210604111632" - }, - "Children": [ - { - "Type": "NodeCodeBlockFenceOpenMarker", - "Data": "```" - }, - { - "Type": "NodeCodeBlockFenceInfoMarker" - }, - { - "ID": "20220307091943-diuexe8", - "Type": "NodeCodeBlockCode", - "Data": ".action{$today := now | date \"20060102150405\"}\n.action{$blocks :=queryBlocks \"SELECT * FROM blocks WHERE content LIKE '?' AND updated \u003e '?' LIMIT ?\" \"%foo%\" $today \"3\"}\n", - "Properties": { - "id": "20220307091943-diuexe8" - } - }, - { - "Type": "NodeCodeBlockFenceCloseMarker", - "Data": "```" - } - ] - }, { "ID": "20210104091309-h71ogwf", "Type": "NodeHeading", diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123004-dplpw0o.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123004-dplpw0o.sy index 7b72c685f..f8f540c50 100644 --- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123004-dplpw0o.sy +++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123004-dplpw0o.sy @@ -6,7 +6,7 @@ "id": "20211226123004-dplpw0o", "title": "範本片段", "type": "doc", - "updated": "20241212164017" + "updated": "20241213215707" }, "Children": [ { @@ -53,7 +53,7 @@ "HeadingLevel": 2, "Properties": { "id": "20211226123024-eyagqur", - "updated": "20241212164017" + "updated": "20241213215707" }, "Children": [ { @@ -208,7 +208,7 @@ "ListData": {}, "Properties": { "id": "20211226123024-pjvw31z", - "updated": "20241212164017" + "updated": "20241213215707" }, "Children": [ { @@ -422,7 +422,7 @@ "Type": "NodeParagraph", "Properties": { "id": "20211226123024-vxjdsno", - "updated": "20240403150942" + "updated": "20241213215430" }, "Children": [ { @@ -436,7 +436,33 @@ }, { "Type": "NodeText", - "Data": "​:該函數用於查詢資料庫,返回值為 blocks 列表,請參考下面的例子" + "Data": "​:該函數用於查詢資料庫,返回值為 blocks 列表" + } + ] + }, + { + "ID": "20241213215519-mfgruqs", + "Type": "NodeCodeBlock", + "IsFencedCodeBlock": true, + "Properties": { + "id": "20241213215519-mfgruqs", + "updated": "20241213215519" + }, + "Children": [ + { + "Type": "NodeCodeBlockFenceOpenMarker", + "Data": "```" + }, + { + "Type": "NodeCodeBlockFenceInfoMarker" + }, + { + "Type": "NodeCodeBlockCode", + "Data": ".action{$today := now | date \"20060102150405\"}\n.action{$blocks :=queryBlocks \"SELECT * FROM blocks WHERE content LIKE '?' AND updated \u003e '?' LIMIT ?\" \"%foo%\" $today \"3\"}\n" + }, + { + "Type": "NodeCodeBlockFenceCloseMarker", + "Data": "```" } ] } @@ -459,7 +485,7 @@ "Type": "NodeParagraph", "Properties": { "id": "20211226123024-4qwyf3w", - "updated": "20240403150944" + "updated": "20241213215431" }, "Children": [ { @@ -473,7 +499,96 @@ }, { "Type": "NodeText", - "Data": "​:該函數用於查詢資料庫,返回值為 spans 列表,請參考下面的例子" + "Data": "​:該函數用於查詢資料庫,返回值為 spans 列表" + } + ] + }, + { + "ID": "20241213215524-9an3khb", + "Type": "NodeCodeBlock", + "IsFencedCodeBlock": true, + "Properties": { + "id": "20241213215524-9an3khb", + "updated": "20241213215524" + }, + "Children": [ + { + "Type": "NodeCodeBlockFenceOpenMarker", + "Data": "```" + }, + { + "Type": "NodeCodeBlockFenceInfoMarker" + }, + { + "Type": "NodeCodeBlockCode", + "Data": " .action{querySQL \"SELECT * FROM spans LIMIT ?\" \"3\"}\n" + }, + { + "Type": "NodeCodeBlockFenceCloseMarker", + "Data": "```" + } + ] + } + ] + }, + { + "ID": "20241213214930-4votv1n", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241213214930-4votv1n", + "updated": "20241213214930" + }, + "Children": [ + { + "ID": "20241213214930-dogaks1", + "Type": "NodeParagraph", + "Properties": { + "id": "20241213214930-dogaks1", + "updated": "20241213215433" + }, + "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, + { + "Type": "NodeTextMark", + "TextMarkType": "code", + "TextMarkTextContent": "querySQL" + }, + { + "Type": "NodeText", + "Data": "​:函數用於查詢資料庫,傳回值為結果集" + } + ] + }, + { + "ID": "20241213215530-f2iwrjz", + "Type": "NodeCodeBlock", + "IsFencedCodeBlock": true, + "Properties": { + "id": "20241213215530-f2iwrjz", + "updated": "20241213215530" + }, + "Children": [ + { + "Type": "NodeCodeBlockFenceOpenMarker", + "Data": "```" + }, + { + "Type": "NodeCodeBlockFenceInfoMarker" + }, + { + "Type": "NodeCodeBlockCode", + "Data": " .action{querySQL \"SELECT * FROM refs LIMIT 3\"}\n" + }, + { + "Type": "NodeCodeBlockFenceCloseMarker", + "Data": "```" } ] } @@ -488,7 +603,7 @@ }, "Properties": { "id": "20241212102019-gassjqt", - "updated": "20241212102113" + "updated": "20241213215707" }, "Children": [ { @@ -515,225 +630,203 @@ ] }, { - "ID": "20241212102021-87matlt", + "ID": "20241213215707-lxpmd6b", + "Type": "NodeCodeBlock", + "IsFencedCodeBlock": true, + "Properties": { + "id": "20241213215707-lxpmd6b", + "updated": "20241213215707" + }, + "Children": [ + { + "Type": "NodeCodeBlockFenceOpenMarker", + "Data": "```" + }, + { + "Type": "NodeCodeBlockFenceInfoMarker" + }, + { + "Type": "NodeCodeBlockCode", + "Data": ".action{ (statBlock .id).RuneCount} .action{ (statBlock .id).WordCount}\n" + }, + { + "Type": "NodeCodeBlockFenceCloseMarker", + "Data": "```" + } + ] + }, + { + "ID": "20241212102021-vj2zyyl", "Type": "NodeList", "ListData": {}, "Properties": { - "id": "20241212102021-87matlt", + "id": "20241212102021-vj2zyyl", "updated": "20241212102021" }, "Children": [ { - "ID": "20241212102021-t2dln9h", + "ID": "20241212102021-92gy6t3", "Type": "NodeListItem", "ListData": { "BulletChar": 42, "Marker": "Kg==" }, "Properties": { - "id": "20241212102021-t2dln9h", + "id": "20241212102021-92gy6t3", "updated": "20241212102021" }, "Children": [ { - "ID": "20241212102021-cfsaes6", + "ID": "20241212102021-d3lo8xu", "Type": "NodeParagraph", "Properties": { - "id": "20241212102021-cfsaes6", + "id": "20241212102021-d3lo8xu", "updated": "20241212102021" }, "Children": [ { "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": ".action{ (statBlock .id).RuneCount} .action{ (statBlock .id).WordCount}" - }, - { - "Type": "NodeText", - "Data": "​" + "Data": "RuneCount" } ] - }, + } + ] + }, + { + "ID": "20241212102021-n8ufevw", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212102021-n8ufevw", + "updated": "20241212102021" + }, + "Children": [ { - "ID": "20241212102021-vj2zyyl", - "Type": "NodeList", - "ListData": {}, + "ID": "20241212102021-omvwh9v", + "Type": "NodeParagraph", "Properties": { - "id": "20241212102021-vj2zyyl", + "id": "20241212102021-omvwh9v", "updated": "20241212102021" }, "Children": [ { - "ID": "20241212102021-92gy6t3", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212102021-92gy6t3", - "updated": "20241212102021" - }, - "Children": [ - { - "ID": "20241212102021-d3lo8xu", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212102021-d3lo8xu", - "updated": "20241212102021" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "RuneCount" - } - ] - } - ] - }, + "Type": "NodeText", + "Data": "WordCount" + } + ] + } + ] + }, + { + "ID": "20241212102021-s12eoe7", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212102021-s12eoe7", + "updated": "20241212102021" + }, + "Children": [ + { + "ID": "20241212102021-518qvnd", + "Type": "NodeParagraph", + "Properties": { + "id": "20241212102021-518qvnd", + "updated": "20241212102021" + }, + "Children": [ { - "ID": "20241212102021-n8ufevw", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212102021-n8ufevw", - "updated": "20241212102021" - }, - "Children": [ - { - "ID": "20241212102021-omvwh9v", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212102021-omvwh9v", - "updated": "20241212102021" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "WordCount" - } - ] - } - ] - }, + "Type": "NodeText", + "Data": "LinkCount" + } + ] + } + ] + }, + { + "ID": "20241212102021-dolb6ct", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212102021-dolb6ct", + "updated": "20241212102021" + }, + "Children": [ + { + "ID": "20241212102021-dx5rhed", + "Type": "NodeParagraph", + "Properties": { + "id": "20241212102021-dx5rhed", + "updated": "20241212102021" + }, + "Children": [ { - "ID": "20241212102021-s12eoe7", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212102021-s12eoe7", - "updated": "20241212102021" - }, - "Children": [ - { - "ID": "20241212102021-518qvnd", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212102021-518qvnd", - "updated": "20241212102021" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "LinkCount" - } - ] - } - ] - }, + "Type": "NodeText", + "Data": "ImageCount" + } + ] + } + ] + }, + { + "ID": "20241212102021-yt0q53w", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212102021-yt0q53w", + "updated": "20241212102021" + }, + "Children": [ + { + "ID": "20241212102021-z97tnzw", + "Type": "NodeParagraph", + "Properties": { + "id": "20241212102021-z97tnzw", + "updated": "20241212102021" + }, + "Children": [ { - "ID": "20241212102021-dolb6ct", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212102021-dolb6ct", - "updated": "20241212102021" - }, - "Children": [ - { - "ID": "20241212102021-dx5rhed", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212102021-dx5rhed", - "updated": "20241212102021" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "ImageCount" - } - ] - } - ] - }, + "Type": "NodeText", + "Data": "RefCount" + } + ] + } + ] + }, + { + "ID": "20241212102021-npgihna", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212102021-npgihna", + "updated": "20241212102021" + }, + "Children": [ + { + "ID": "20241212102021-80qheu7", + "Type": "NodeParagraph", + "Properties": { + "id": "20241212102021-80qheu7", + "updated": "20241212102021" + }, + "Children": [ { - "ID": "20241212102021-yt0q53w", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212102021-yt0q53w", - "updated": "20241212102021" - }, - "Children": [ - { - "ID": "20241212102021-z97tnzw", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212102021-z97tnzw", - "updated": "20241212102021" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "RefCount" - } - ] - } - ] - }, - { - "ID": "20241212102021-npgihna", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212102021-npgihna", - "updated": "20241212102021" - }, - "Children": [ - { - "ID": "20241212102021-80qheu7", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212102021-80qheu7", - "updated": "20241212102021" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "BlockCount" - } - ] - } - ] + "Type": "NodeText", + "Data": "BlockCount" } ] } @@ -1151,64 +1244,6 @@ } ] }, - { - "ID": "20211226123024-5rk6w30", - "Type": "NodeParagraph", - "Properties": { - "id": "20211226123024-5rk6w30", - "updated": "20211228134953" - }, - "Children": [ - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "queryBlocks" - }, - { - "Type": "NodeText", - "Data": " 和 " - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "querySpans" - }, - { - "Type": "NodeText", - "Data": " 支援類似 SQL 預編譯語句的變參列表,方便傳入參數:" - } - ] - }, - { - "ID": "20211226123024-sw1k190", - "Type": "NodeCodeBlock", - "IsFencedCodeBlock": true, - "Properties": { - "id": "20211226123024-sw1k190", - "updated": "20211225221841" - }, - "Children": [ - { - "Type": "NodeCodeBlockFenceOpenMarker", - "Data": "```" - }, - { - "Type": "NodeCodeBlockFenceInfoMarker" - }, - { - "ID": "20220307092237-mawslux", - "Type": "NodeCodeBlockCode", - "Data": ".action{$today := now | date \"20060102150405\"}\n.action{$blocks :=queryBlocks \"SELECT * FROM blocks WHERE content LIKE '?' AND updated \u003e '?' LIMIT ?\" \"%foo%\" $today \"3\"}\n", - "Properties": { - "id": "20220307092237-mawslux" - } - }, - { - "Type": "NodeCodeBlockFenceCloseMarker", - "Data": "```" - } - ] - }, { "ID": "20211226123024-3wiifft", "Type": "NodeHeading", diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-6x9ivi7.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-6x9ivi7.sy index 25ebb055d..83a7c9c92 100644 --- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-6x9ivi7.sy +++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-6x9ivi7.sy @@ -7,7 +7,7 @@ "id": "20240530101000-6x9ivi7", "title": "テンプレートスニペット", "type": "doc", - "updated": "20241212163955" + "updated": "20241213215720" }, "Children": [ { @@ -66,7 +66,7 @@ "Properties": { "ID": "20240530101000-5nvn9ad", "id": "20240530101000-pi05yzt", - "updated": "20241212163955" + "updated": "20241213215720" }, "Children": [ { @@ -226,7 +226,7 @@ "ListData": {}, "Properties": { "id": "20240530101000-by5hqnb", - "updated": "20241212163955" + "updated": "20241213215720" }, "Children": [ { @@ -440,7 +440,7 @@ "Type": "NodeParagraph", "Properties": { "id": "20240530101000-obb5zo9", - "updated": "20240530101000" + "updated": "20241213215612" }, "Children": [ { @@ -454,7 +454,33 @@ }, { "Type": "NodeText", - "Data": "​: この関数はデータベースをクエリしてブロックのリストを返します (下記の使用例を参照してください)" + "Data": "​: この関数はデータベースをクエリしてブロックのリストを返します" + } + ] + }, + { + "ID": "20241213215628-5gixpmp", + "Type": "NodeCodeBlock", + "IsFencedCodeBlock": true, + "Properties": { + "id": "20241213215628-5gixpmp", + "updated": "20241213215628" + }, + "Children": [ + { + "Type": "NodeCodeBlockFenceOpenMarker", + "Data": "```" + }, + { + "Type": "NodeCodeBlockFenceInfoMarker" + }, + { + "Type": "NodeCodeBlockCode", + "Data": ".action{$today := now | date \"20060102150405\"}\n.action{$blocks :=queryBlocks \"SELECT * FROM blocks WHERE content LIKE '?' AND updated \u003e '?' LIMIT ?\" \"%foo%\" $today \"3\"}\n" + }, + { + "Type": "NodeCodeBlockFenceCloseMarker", + "Data": "```" } ] } @@ -477,7 +503,7 @@ "Type": "NodeParagraph", "Properties": { "id": "20240530101000-4wi25sk", - "updated": "20240530101000" + "updated": "20241213215614" }, "Children": [ { @@ -491,7 +517,96 @@ }, { "Type": "NodeText", - "Data": "​: この関数はデータベースをクエリしてスパンのリストを返します (下記の使用例を参照してください)" + "Data": "​: この関数はデータベースをクエリしてスパンのリストを返します" + } + ] + }, + { + "ID": "20241213215619-gkqs282", + "Type": "NodeCodeBlock", + "IsFencedCodeBlock": true, + "Properties": { + "id": "20241213215619-gkqs282", + "updated": "20241213215619" + }, + "Children": [ + { + "Type": "NodeCodeBlockFenceOpenMarker", + "Data": "```" + }, + { + "Type": "NodeCodeBlockFenceInfoMarker" + }, + { + "Type": "NodeCodeBlockCode", + "Data": " .action{querySQL \"SELECT * FROM spans LIMIT ?\" \"3\"}\n" + }, + { + "Type": "NodeCodeBlockFenceCloseMarker", + "Data": "```" + } + ] + } + ] + }, + { + "ID": "20241213215009-qrtc56j", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241213215009-qrtc56j", + "updated": "20241213215009" + }, + "Children": [ + { + "ID": "20241213215009-fev1gao", + "Type": "NodeParagraph", + "Properties": { + "id": "20241213215009-fev1gao", + "updated": "20241213215617" + }, + "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, + { + "Type": "NodeTextMark", + "TextMarkType": "code", + "TextMarkTextContent": "querySQL" + }, + { + "Type": "NodeText", + "Data": "​: この関数はデータベースへのクエリに使用され、戻り値は結果セットです" + } + ] + }, + { + "ID": "20241213215633-69ltmv1", + "Type": "NodeCodeBlock", + "IsFencedCodeBlock": true, + "Properties": { + "id": "20241213215633-69ltmv1", + "updated": "20241213215633" + }, + "Children": [ + { + "Type": "NodeCodeBlockFenceOpenMarker", + "Data": "```" + }, + { + "Type": "NodeCodeBlockFenceInfoMarker" + }, + { + "Type": "NodeCodeBlockCode", + "Data": " .action{querySQL \"SELECT * FROM refs LIMIT 3\"}\n" + }, + { + "Type": "NodeCodeBlockFenceCloseMarker", + "Data": "```" } ] } @@ -506,7 +621,7 @@ }, "Properties": { "id": "20241212102033-rn9u6t8", - "updated": "20241212102145" + "updated": "20241213215720" }, "Children": [ { @@ -533,225 +648,203 @@ ] }, { - "ID": "20241212102033-kyrog1c", + "ID": "20241213215720-ueqpsna", + "Type": "NodeCodeBlock", + "IsFencedCodeBlock": true, + "Properties": { + "id": "20241213215720-ueqpsna", + "updated": "20241213215720" + }, + "Children": [ + { + "Type": "NodeCodeBlockFenceOpenMarker", + "Data": "```" + }, + { + "Type": "NodeCodeBlockFenceInfoMarker" + }, + { + "Type": "NodeCodeBlockCode", + "Data": ".action{ (statBlock .id).RuneCount} .action{ (statBlock .id).WordCount}\n" + }, + { + "Type": "NodeCodeBlockFenceCloseMarker", + "Data": "```" + } + ] + }, + { + "ID": "20241212102033-ib8fdwx", "Type": "NodeList", "ListData": {}, "Properties": { - "id": "20241212102033-kyrog1c", + "id": "20241212102033-ib8fdwx", "updated": "20241212102033" }, "Children": [ { - "ID": "20241212102033-i3cnp1o", + "ID": "20241212102033-lijk8pe", "Type": "NodeListItem", "ListData": { "BulletChar": 42, "Marker": "Kg==" }, "Properties": { - "id": "20241212102033-i3cnp1o", + "id": "20241212102033-lijk8pe", "updated": "20241212102033" }, "Children": [ { - "ID": "20241212102033-4vbgh1y", + "ID": "20241212102033-ch66lvd", "Type": "NodeParagraph", "Properties": { - "id": "20241212102033-4vbgh1y", + "id": "20241212102033-ch66lvd", "updated": "20241212102033" }, "Children": [ { "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": ".action{ (statBlock .id).RuneCount} .action{ (statBlock .id).WordCount}" - }, - { - "Type": "NodeText", - "Data": "​" + "Data": "RuneCount" } ] - }, + } + ] + }, + { + "ID": "20241212102033-527kxt0", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212102033-527kxt0", + "updated": "20241212102033" + }, + "Children": [ { - "ID": "20241212102033-ib8fdwx", - "Type": "NodeList", - "ListData": {}, + "ID": "20241212102033-7iop2es", + "Type": "NodeParagraph", "Properties": { - "id": "20241212102033-ib8fdwx", + "id": "20241212102033-7iop2es", "updated": "20241212102033" }, "Children": [ { - "ID": "20241212102033-lijk8pe", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212102033-lijk8pe", - "updated": "20241212102033" - }, - "Children": [ - { - "ID": "20241212102033-ch66lvd", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212102033-ch66lvd", - "updated": "20241212102033" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "RuneCount" - } - ] - } - ] - }, + "Type": "NodeText", + "Data": "WordCount" + } + ] + } + ] + }, + { + "ID": "20241212102033-zicftlk", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212102033-zicftlk", + "updated": "20241212102033" + }, + "Children": [ + { + "ID": "20241212102033-871ju7g", + "Type": "NodeParagraph", + "Properties": { + "id": "20241212102033-871ju7g", + "updated": "20241212102033" + }, + "Children": [ { - "ID": "20241212102033-527kxt0", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212102033-527kxt0", - "updated": "20241212102033" - }, - "Children": [ - { - "ID": "20241212102033-7iop2es", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212102033-7iop2es", - "updated": "20241212102033" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "WordCount" - } - ] - } - ] - }, + "Type": "NodeText", + "Data": "LinkCount" + } + ] + } + ] + }, + { + "ID": "20241212102033-2k2gz3h", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212102033-2k2gz3h", + "updated": "20241212102033" + }, + "Children": [ + { + "ID": "20241212102033-1ss2d9y", + "Type": "NodeParagraph", + "Properties": { + "id": "20241212102033-1ss2d9y", + "updated": "20241212102033" + }, + "Children": [ { - "ID": "20241212102033-zicftlk", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212102033-zicftlk", - "updated": "20241212102033" - }, - "Children": [ - { - "ID": "20241212102033-871ju7g", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212102033-871ju7g", - "updated": "20241212102033" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "LinkCount" - } - ] - } - ] - }, + "Type": "NodeText", + "Data": "ImageCount" + } + ] + } + ] + }, + { + "ID": "20241212102033-905g5ga", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212102033-905g5ga", + "updated": "20241212102033" + }, + "Children": [ + { + "ID": "20241212102033-k7jgqz4", + "Type": "NodeParagraph", + "Properties": { + "id": "20241212102033-k7jgqz4", + "updated": "20241212102033" + }, + "Children": [ { - "ID": "20241212102033-2k2gz3h", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212102033-2k2gz3h", - "updated": "20241212102033" - }, - "Children": [ - { - "ID": "20241212102033-1ss2d9y", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212102033-1ss2d9y", - "updated": "20241212102033" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "ImageCount" - } - ] - } - ] - }, + "Type": "NodeText", + "Data": "RefCount" + } + ] + } + ] + }, + { + "ID": "20241212102033-xbpy9ew", + "Type": "NodeListItem", + "ListData": { + "BulletChar": 42, + "Marker": "Kg==" + }, + "Properties": { + "id": "20241212102033-xbpy9ew", + "updated": "20241212102033" + }, + "Children": [ + { + "ID": "20241212102033-kvquhrn", + "Type": "NodeParagraph", + "Properties": { + "id": "20241212102033-kvquhrn", + "updated": "20241212102033" + }, + "Children": [ { - "ID": "20241212102033-905g5ga", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212102033-905g5ga", - "updated": "20241212102033" - }, - "Children": [ - { - "ID": "20241212102033-k7jgqz4", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212102033-k7jgqz4", - "updated": "20241212102033" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "RefCount" - } - ] - } - ] - }, - { - "ID": "20241212102033-xbpy9ew", - "Type": "NodeListItem", - "ListData": { - "BulletChar": 42, - "Marker": "Kg==" - }, - "Properties": { - "id": "20241212102033-xbpy9ew", - "updated": "20241212102033" - }, - "Children": [ - { - "ID": "20241212102033-kvquhrn", - "Type": "NodeParagraph", - "Properties": { - "id": "20241212102033-kvquhrn", - "updated": "20241212102033" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "BlockCount" - } - ] - } - ] + "Type": "NodeText", + "Data": "BlockCount" } ] } @@ -1169,71 +1262,6 @@ } ] }, - { - "ID": "20240530101000-5twj99z", - "Type": "NodeParagraph", - "Properties": { - "ID": "20240530101000-p45pa4c", - "id": "20240530101000-5twj99z", - "updated": "20240530101000" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "​" - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "queryBlocks" - }, - { - "Type": "NodeText", - "Data": "​ と " - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "querySpans" - }, - { - "Type": "NodeText", - "Data": "​ はパラメータの入力を容易にするために、SQL のプリペアドステートメントに似た可変長引数リストをサポートしています:" - } - ] - }, - { - "ID": "20240530101000-ao36z4x", - "Type": "NodeCodeBlock", - "IsFencedCodeBlock": true, - "Properties": { - "ID": "20240530101000-2pwl178", - "id": "20240530101000-ao36z4x", - "updated": "20240530101000" - }, - "Children": [ - { - "Type": "NodeCodeBlockFenceOpenMarker", - "Data": "```" - }, - { - "Type": "NodeCodeBlockFenceInfoMarker" - }, - { - "ID": "20240530101000-ry5jzum", - "Type": "NodeCodeBlockCode", - "Data": ".action{$today := now | date \"20060102150405\"}\n.action{$blocks :=queryBlocks \"SELECT * FROM blocks WHERE content LIKE '?' AND updated \u003e '?' LIMIT ?\" \"%foo%\" $today \"3\"}\n", - "Properties": { - "ID": "20240530101000-i3tqwi3", - "id": "20240530101000-ry5jzum" - } - }, - { - "Type": "NodeCodeBlockFenceCloseMarker", - "Data": "```" - } - ] - }, { "ID": "20240530101000-ud82uol", "Type": "NodeHeading", diff --git a/kernel/sql/database.go b/kernel/sql/database.go index 2ffcd93c7..1577463e5 100644 --- a/kernel/sql/database.go +++ b/kernel/sql/database.go @@ -1513,4 +1513,8 @@ func SQLTemplateFuncs(templateFuncMap *template.FuncMap) { retSpans = SelectSpansRawStmt(stmt, 512) return } + (*templateFuncMap)["querySQL"] = func(stmt string) (ret []map[string]interface{}) { + ret, _ = Query(stmt, 1024) + return + } }