From 87ed549eae57b7d3d6b31ddf2ab3a48bd83279f2 Mon Sep 17 00:00:00 2001 From: "Sinan Sonmez (Chaush)" Date: Fri, 29 Jul 2022 16:05:43 +0000 Subject: [PATCH 01/11] write What, syntax and how to run --- website/πŸ”Œ Query.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/website/πŸ”Œ Query.md b/website/πŸ”Œ Query.md index 11772cf6..3c187840 100644 --- a/website/πŸ”Œ Query.md +++ b/website/πŸ”Œ Query.md @@ -5,4 +5,24 @@ repo: https://github.com/silverbulletmd/silverbullet author: Silver Bullet Authors ``` -The query plug is a built-in plug implementing the `` mechanism. \ No newline at end of file +### What? +The query plug is a built-in plug implementing the `` mechanism. You can use query plug to automatically receive information from your notes. + +### Syntax +1. start with: `` +2. end with: `` +3. write your query: replace `[QUERY GOES HERE]` with any query you want using options below +4. available query options: Usage of options is similar to general query language except special render option. Render option is to use display the data in a format that you created in a separate template + * `where` + * `order` + * `limit` + * `select` + * `render` +5. If you are a developer or have a technical knowledge to read a code and would like to know more about syntax please check out [query grammar](https://github.com/silverbulletmd/silverbullet/blob/main/packages/plugs/query/query.grammar) + +### How to run a query +After writing the query, there are two options +* Open the **command palette** and run **Materialized Queries: Update** +* Use shortcut: for windows **Alt-q** and for mac **Option-q** + +After using one of the options, the data will be displayed. \ No newline at end of file From 4e60d4e514fe8f0e776683ed84cff9c4e5ad876e Mon Sep 17 00:00:00 2001 From: "Sinan Sonmez (Chaush)" Date: Sat, 30 Jul 2022 11:03:57 +0000 Subject: [PATCH 02/11] update how to run a query --- website/πŸ”Œ Query.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/πŸ”Œ Query.md b/website/πŸ”Œ Query.md index 3c187840..16a2945c 100644 --- a/website/πŸ”Œ Query.md +++ b/website/πŸ”Œ Query.md @@ -23,6 +23,7 @@ The query plug is a built-in plug implementing the `` mechanism. ### How to run a query After writing the query, there are two options * Open the **command palette** and run **Materialized Queries: Update** -* Use shortcut: for windows **Alt-q** and for mac **Option-q** +* Use shortcut: for windows **Alt-q** and for mac **Option-q** +* Go to another page and come back to the page where query is located After using one of the options, the data will be displayed. \ No newline at end of file From a3cd0faacca201790aefdd1d6895703a29585906 Mon Sep 17 00:00:00 2001 From: "Sinan Sonmez (Chaush)" Date: Sat, 30 Jul 2022 11:11:24 +0000 Subject: [PATCH 03/11] builtin data sources --- website/πŸ”Œ Query.md | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/website/πŸ”Œ Query.md b/website/πŸ”Œ Query.md index 16a2945c..026b2445 100644 --- a/website/πŸ”Œ Query.md +++ b/website/πŸ”Œ Query.md @@ -5,10 +5,10 @@ repo: https://github.com/silverbulletmd/silverbullet author: Silver Bullet Authors ``` -### What? +### 1. What? The query plug is a built-in plug implementing the `` mechanism. You can use query plug to automatically receive information from your notes. -### Syntax +### 2. Syntax 1. start with: `` 2. end with: `` 3. write your query: replace `[QUERY GOES HERE]` with any query you want using options below @@ -20,10 +20,32 @@ The query plug is a built-in plug implementing the `` mechanism. * `render` 5. If you are a developer or have a technical knowledge to read a code and would like to know more about syntax please check out [query grammar](https://github.com/silverbulletmd/silverbullet/blob/main/packages/plugs/query/query.grammar) -### How to run a query +### 3. How to run a query? After writing the query, there are two options * Open the **command palette** and run **Materialized Queries: Update** * Use shortcut: for windows **Alt-q** and for mac **Option-q** * Go to another page and come back to the page where query is located -After using one of the options, the data will be displayed. \ No newline at end of file +After using one of the options, the data will be displayed. + +### 4. Data sources +Available data sources can be categorized as +1. Builtin data sources +2. Data that can be inserted by users +3. Plug’s data sourcer + +Best part about data sources: there is an auto completion πŸŽ‰. Start writing ` + + + + From acb8d068eef3301e815f9f043090c2f570567135 Mon Sep 17 00:00:00 2001 From: "Sinan Sonmez (Chaush)" Date: Sat, 30 Jul 2022 11:13:43 +0000 Subject: [PATCH 04/11] special data --- website/πŸ”Œ Query.md | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/website/πŸ”Œ Query.md b/website/πŸ”Œ Query.md index 026b2445..f5af2b2e 100644 --- a/website/πŸ”Œ Query.md +++ b/website/πŸ”Œ Query.md @@ -32,7 +32,7 @@ After using one of the options, the data will be displayed. Available data sources can be categorized as 1. Builtin data sources 2. Data that can be inserted by users -3. Plug’s data sourcer +3. Plug’s data sources Best part about data sources: there is an auto completion πŸŽ‰. Start writing ` - +#### 4.2 Data that can be inserted by users +* *insert the data:* You can insert a data using the syntax below +```data +name: John +age: 50 +city: Milan +country: Italy +--- +name: Jane +age: 53 +city: Rome +country: Italy +--- +name: Francesco +age: 28 +city: Berlin +country: Germany +``` +* *query the data:* You can query the data using `data` option + +|name|age|city |country|page |pos | +|----|--|-----|-----|---------------|----| +|John|50|Milan|Italy|Test Data Query|0 | +|Jane|53|Rome |Italy|Test Data Query|46 | +|John|50|Milan|Italy|πŸ”Œ Query |2148| +|Jane|53|Rome |Italy|πŸ”Œ Query |2194| From 3f15316ac933c6a0dd180ceea99e83eb38ee8a2b Mon Sep 17 00:00:00 2001 From: "Sinan Sonmez (Chaush)" Date: Sat, 30 Jul 2022 11:16:40 +0000 Subject: [PATCH 05/11] Plug data sources --- website/πŸ”Œ Query.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/website/πŸ”Œ Query.md b/website/πŸ”Œ Query.md index f5af2b2e..52f1d1d9 100644 --- a/website/πŸ”Œ Query.md +++ b/website/πŸ”Œ Query.md @@ -72,4 +72,8 @@ country: Germany |Jane|53|Rome |Italy|πŸ”Œ Query |2194| - +#### 4.3 Plugs’ data sources +Certain plugs can also give you special options to query a certain data. Some examples are +* [[πŸ”Œ Github]] provides `gh-pull` to query PRs for selected repo +* [[πŸ”Œ Mattermost]] provides `mm-saved` to fetch (by default 15) saved posts in Mattermost +For complete list of data sources, please check plugs’ pages From 3bc738088aab426d777136691262c857b8cca145 Mon Sep 17 00:00:00 2001 From: "Sinan Sonmez (Chaush)" Date: Sat, 30 Jul 2022 11:22:41 +0000 Subject: [PATCH 06/11] simple query --- website/πŸ”Œ Query.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/website/πŸ”Œ Query.md b/website/πŸ”Œ Query.md index 52f1d1d9..9de929f3 100644 --- a/website/πŸ”Œ Query.md +++ b/website/πŸ”Œ Query.md @@ -77,3 +77,31 @@ Certain plugs can also give you special options to query a certain data. Some ex * [[πŸ”Œ Github]] provides `gh-pull` to query PRs for selected repo * [[πŸ”Œ Mattermost]] provides `mm-saved` to fetch (by default 15) saved posts in Mattermost For complete list of data sources, please check plugs’ pages + +### 5. Examples +We will walk you through a set of example starting from very basic one all the way to format the data using templates. + +Our goal in this exercise is to (i) get all plug pages (ii) ordered by last modified time and (iii) display in a nice format. + +For the sake of simplicity, we will use `page` data source and limit the results not to spoil the page. + +#### 5.1 Simple query without any condition +We would like to get the list of all pages. + +Look at the data. This is more than we need. The query even gives us template pages. Lets try to limit it in the next step + +|name |lastModified |perm|tags |type|uri |repo |author | +|--|--|--|--|--|--|--|--| +|index |1659178324609|rw|undefined|undefined|undefined |undefined |undefined | +|Mattermost Plugin|1659108035000|rw|undefined|undefined|undefined |undefined |undefined | +|PLUGS |1659108634000|rw|undefined|undefined|undefined |undefined |undefined | +|Test Data Query |1659179547936|rw|undefined|undefined|undefined |undefined |undefined | +|template/plug |1659108035000|rw|undefined|undefined|undefined |undefined |undefined | +|template/tasks |1659108035000|rw|#each|undefined|undefined |undefined |undefined | +|πŸ’‘ Inspiration |1659108035000|rw|undefined|undefined|undefined |undefined |undefined | +|πŸ”Œ Backlinks |1659108035000|rw|undefined|plug|ghr:Willyfrog/silverbullet-backlinks |https://github.com/Willyfrog/silverbullet-backlinks |Guillermo VayΓ‘| +|πŸ”Œ Ghost |1659108035000|rw|undefined|plug|github:silverbulletmd/silverbullet-ghost/ghost.plug.json |https://github.com/silverbulletmd/silverbullet-ghost |Zef Hemel | +|πŸ”Œ Git |1659108035000|rw|undefined|plug|github:silverbulletmd/silverbullet-github/github.plug.json|https://github.com/silverbulletmd/silverbullet-github|Zef Hemel | + + +#### 5.2 Simple query without a condition From 8bc9e626fbcb3be673862069ec298ca33be415a6 Mon Sep 17 00:00:00 2001 From: "Sinan Sonmez (Chaush)" Date: Sat, 30 Jul 2022 11:24:23 +0000 Subject: [PATCH 07/11] Simple query without a condition --- website/πŸ”Œ Query.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/website/πŸ”Œ Query.md b/website/πŸ”Œ Query.md index 9de929f3..4adb6b97 100644 --- a/website/πŸ”Œ Query.md +++ b/website/πŸ”Œ Query.md @@ -105,3 +105,15 @@ Look at the data. This is more than we need. The query even gives us template pa #### 5.2 Simple query without a condition +We would like to get all plug pages and sorted by last modified time + + +|name |lastModified |perm|type|uri |repo |author | +|--|--|--|--|--|--|--| +|πŸ”Œ Query |1659180237743|rw|plug|core:query |https://github.com/silverbulletmd/silverbullet |Silver Bullet Authors| +|πŸ”Œ Mattermost|1659111156000|rw|plug|github:silverbulletmd/silverbullet-mattermost/mattermost.plug.json|https://github.com/silverbulletmd/silverbullet-mattermost|Zef Hemel | +|πŸ”Œ Backlinks |1659108035000|rw|plug|ghr:Willyfrog/silverbullet-backlinks |https://github.com/Willyfrog/silverbullet-backlinks |Guillermo VayΓ‘ | +|πŸ”Œ Ghost |1659108035000|rw|plug|github:silverbulletmd/silverbullet-ghost/ghost.plug.json |https://github.com/silverbulletmd/silverbullet-ghost |Zef Hemel | +|πŸ”Œ Git |1659108035000|rw|plug|github:silverbulletmd/silverbullet-github/github.plug.json |https://github.com/silverbulletmd/silverbullet-github |Zef Hemel | + + From 589e2bd05ec92f24bca97e7e4f9972250e421016 Mon Sep 17 00:00:00 2001 From: "Sinan Sonmez (Chaush)" Date: Sat, 30 Jul 2022 11:29:23 +0000 Subject: [PATCH 08/11] Query to select only certain fields --- website/πŸ”Œ Query.md | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/website/πŸ”Œ Query.md b/website/πŸ”Œ Query.md index 4adb6b97..c32c118a 100644 --- a/website/πŸ”Œ Query.md +++ b/website/πŸ”Œ Query.md @@ -86,9 +86,9 @@ Our goal in this exercise is to (i) get all plug pages (ii) ordered by last modi For the sake of simplicity, we will use `page` data source and limit the results not to spoil the page. #### 5.1 Simple query without any condition -We would like to get the list of all pages. +**Goal:** We would like to get the list of all pages. -Look at the data. This is more than we need. The query even gives us template pages. Lets try to limit it in the next step +**Result:** Look at the data. This is more than we need. The query even gives us template pages. Lets try to limit it in the next step |name |lastModified |perm|tags |type|uri |repo |author | |--|--|--|--|--|--|--|--| @@ -105,15 +105,34 @@ Look at the data. This is more than we need. The query even gives us template pa #### 5.2 Simple query without a condition -We would like to get all plug pages and sorted by last modified time +**Goal:** We would like to get all plug pages and sorted by last modified time + +**Result:** Okay, this what we wanted but there are also information such as perm, type and lastModified that we don't want to show in the page |name |lastModified |perm|type|uri |repo |author | |--|--|--|--|--|--|--| -|πŸ”Œ Query |1659180237743|rw|plug|core:query |https://github.com/silverbulletmd/silverbullet |Silver Bullet Authors| +|πŸ”Œ Query |1659180321311|rw|plug|core:query |https://github.com/silverbulletmd/silverbullet |Silver Bullet Authors| |πŸ”Œ Mattermost|1659111156000|rw|plug|github:silverbulletmd/silverbullet-mattermost/mattermost.plug.json|https://github.com/silverbulletmd/silverbullet-mattermost|Zef Hemel | |πŸ”Œ Backlinks |1659108035000|rw|plug|ghr:Willyfrog/silverbullet-backlinks |https://github.com/Willyfrog/silverbullet-backlinks |Guillermo VayΓ‘ | |πŸ”Œ Ghost |1659108035000|rw|plug|github:silverbulletmd/silverbullet-ghost/ghost.plug.json |https://github.com/silverbulletmd/silverbullet-ghost |Zef Hemel | |πŸ”Œ Git |1659108035000|rw|plug|github:silverbulletmd/silverbullet-github/github.plug.json |https://github.com/silverbulletmd/silverbullet-github |Zef Hemel | + +#### 5.3 Query to select only certain fields +**Goal:** We would like to get all plug pages, select only `name` and `uri` column and sort by last modified time and + +**Result:** Okay, this is much better. However, I believe this needs a touch from a visual perspective + + +|name |uri | +|--|--| +|πŸ”Œ Query |core:query | +|πŸ”Œ Mattermost|github:silverbulletmd/silverbullet-mattermost/mattermost.plug.json| +|πŸ”Œ Backlinks |ghr:Willyfrog/silverbullet-backlinks | +|πŸ”Œ Ghost |github:silverbulletmd/silverbullet-ghost/ghost.plug.json | +|πŸ”Œ Git |github:silverbulletmd/silverbullet-github/github.plug.json | + + +#### 5.4 Query to select only certain fields \ No newline at end of file From 803e0ed77c504d73deae7f04414faa95e6b7b34f Mon Sep 17 00:00:00 2001 From: "Sinan Sonmez (Chaush)" Date: Sat, 30 Jul 2022 11:36:25 +0000 Subject: [PATCH 09/11] final query --- website/πŸ”Œ Query.md | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/website/πŸ”Œ Query.md b/website/πŸ”Œ Query.md index c32c118a..9a156bf2 100644 --- a/website/πŸ”Œ Query.md +++ b/website/πŸ”Œ Query.md @@ -112,7 +112,7 @@ For the sake of simplicity, we will use `page` data source and limit the results |name |lastModified |perm|type|uri |repo |author | |--|--|--|--|--|--|--| -|πŸ”Œ Query |1659180321311|rw|plug|core:query |https://github.com/silverbulletmd/silverbullet |Silver Bullet Authors| +|πŸ”Œ Query |1659180816719|rw|plug|core:query |https://github.com/silverbulletmd/silverbullet |Silver Bullet Authors| |πŸ”Œ Mattermost|1659111156000|rw|plug|github:silverbulletmd/silverbullet-mattermost/mattermost.plug.json|https://github.com/silverbulletmd/silverbullet-mattermost|Zef Hemel | |πŸ”Œ Backlinks |1659108035000|rw|plug|ghr:Willyfrog/silverbullet-backlinks |https://github.com/Willyfrog/silverbullet-backlinks |Guillermo VayΓ‘ | |πŸ”Œ Ghost |1659108035000|rw|plug|github:silverbulletmd/silverbullet-ghost/ghost.plug.json |https://github.com/silverbulletmd/silverbullet-ghost |Zef Hemel | @@ -125,14 +125,26 @@ For the sake of simplicity, we will use `page` data source and limit the results **Result:** Okay, this is much better. However, I believe this needs a touch from a visual perspective - -|name |uri | -|--|--| -|πŸ”Œ Query |core:query | -|πŸ”Œ Mattermost|github:silverbulletmd/silverbullet-mattermost/mattermost.plug.json| -|πŸ”Œ Backlinks |ghr:Willyfrog/silverbullet-backlinks | -|πŸ”Œ Ghost |github:silverbulletmd/silverbullet-ghost/ghost.plug.json | -|πŸ”Œ Git |github:silverbulletmd/silverbullet-github/github.plug.json | + +|name |author |repo | +|--|--|--| +|πŸ”Œ Query |Silver Bullet Authors|https://github.com/silverbulletmd/silverbullet | +|πŸ”Œ Mattermost|Zef Hemel |https://github.com/silverbulletmd/silverbullet-mattermost| +|πŸ”Œ Backlinks |Guillermo VayΓ‘ |https://github.com/Willyfrog/silverbullet-backlinks | +|πŸ”Œ Ghost |Zef Hemel |https://github.com/silverbulletmd/silverbullet-ghost | +|πŸ”Œ Git |Zef Hemel |https://github.com/silverbulletmd/silverbullet-github | -#### 5.4 Query to select only certain fields \ No newline at end of file +#### 5.4 Display the data in a format defined by a template + +**Goal:** We would like to display the data from 5.3 in a nice format using bullet points with links to Plug pages, with author name and link to their GitHub repo. + +**Result:** Here you go this is the result we would like to achieve πŸŽ‰. Did you see how I used `render` and `template/plug` in a query? πŸš€ + + +* [[πŸ”Œ Query]] by **Silver Bullet Authors** ([repo](https://github.com/silverbulletmd/silverbullet)) +* [[πŸ”Œ Mattermost]] by **Zef Hemel** ([repo](https://github.com/silverbulletmd/silverbullet-mattermost)) +* [[πŸ”Œ Backlinks]] by **Guillermo VayΓ‘** ([repo](https://github.com/Willyfrog/silverbullet-backlinks)) +* [[πŸ”Œ Ghost]] by **Zef Hemel** ([repo](https://github.com/silverbulletmd/silverbullet-ghost)) +* [[πŸ”Œ Git]] by **Zef Hemel** ([repo](https://github.com/silverbulletmd/silverbullet-github)) + \ No newline at end of file From 9cb8be6d0309a2c8335cf149f01c5aae526c435f Mon Sep 17 00:00:00 2001 From: "Sinan Sonmez (Chaush)" Date: Sat, 30 Jul 2022 11:52:41 +0000 Subject: [PATCH 10/11] improve the format --- website/πŸ”Œ Query.md | 73 +++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 29 deletions(-) diff --git a/website/πŸ”Œ Query.md b/website/πŸ”Œ Query.md index 9a156bf2..4392bfd4 100644 --- a/website/πŸ”Œ Query.md +++ b/website/πŸ”Œ Query.md @@ -9,43 +9,46 @@ author: Silver Bullet Authors The query plug is a built-in plug implementing the `` mechanism. You can use query plug to automatically receive information from your notes. ### 2. Syntax -1. start with: `` -2. end with: `` -3. write your query: replace `[QUERY GOES HERE]` with any query you want using options below -4. available query options: Usage of options is similar to general query language except special render option. Render option is to use display the data in a format that you created in a separate template +1. _start with_: `` +2. _end with_: `` +3. _write your query_: replace `[QUERY GOES HERE]` with any query you want using options below +4. _available query options_: Usage of options is similar to general query language except special render option. Render option is to use display the data in a format that you created in a separate template * `where` * `order` * `limit` * `select` * `render` -5. If you are a developer or have a technical knowledge to read a code and would like to know more about syntax please check out [query grammar](https://github.com/silverbulletmd/silverbullet/blob/main/packages/plugs/query/query.grammar) + +P.S.: If you are a developer or have a technical knowledge to read a code and would like to know more about syntax, please check out [query grammar](https://github.com/silverbulletmd/silverbullet/blob/main/packages/plugs/query/query.grammar). ### 3. How to run a query? -After writing the query, there are two options +After writing the query, there are three options: * Open the **command palette** and run **Materialized Queries: Update** -* Use shortcut: for windows **Alt-q** and for mac **Option-q** +* Use shortcut: hit **Alt-q** (Windows, Linux) or **Option-q** (Mac) * Go to another page and come back to the page where query is located After using one of the options, the data will be displayed. ### 4. Data sources -Available data sources can be categorized as +Available data sources can be categorized as: 1. Builtin data sources 2. Data that can be inserted by users 3. Plug’s data sources -Best part about data sources: there is an auto completion πŸŽ‰. Start writing ` #### 4.3 Plugs’ data sources -Certain plugs can also give you special options to query a certain data. Some examples are +Certain plugs can also provide special data sources to query a certain data. Some examples are * [[πŸ”Œ Github]] provides `gh-pull` to query PRs for selected repo * [[πŸ”Œ Mattermost]] provides `mm-saved` to fetch (by default 15) saved posts in Mattermost -For complete list of data sources, please check plugs’ pages + +For complete list of data sources, please check plugs’ pages. ### 5. Examples -We will walk you through a set of example starting from very basic one all the way to format the data using templates. +We will walk you through a set of examples starting from very basic one until to format the data using templates. Our goal in this exercise is to (i) get all plug pages (ii) ordered by last modified time and (iii) display in a nice format. @@ -88,7 +92,7 @@ For the sake of simplicity, we will use `page` data source and limit the results #### 5.1 Simple query without any condition **Goal:** We would like to get the list of all pages. -**Result:** Look at the data. This is more than we need. The query even gives us template pages. Lets try to limit it in the next step +**Result:** Look at the data. This is more than we need. The query even gives us template pages. Lets try to limit it in the next step. |name |lastModified |perm|tags |type|uri |repo |author | |--|--|--|--|--|--|--|--| @@ -104,15 +108,15 @@ For the sake of simplicity, we will use `page` data source and limit the results |πŸ”Œ Git |1659108035000|rw|undefined|plug|github:silverbulletmd/silverbullet-github/github.plug.json|https://github.com/silverbulletmd/silverbullet-github|Zef Hemel | -#### 5.2 Simple query without a condition -**Goal:** We would like to get all plug pages and sorted by last modified time +#### 5.2 Simple query with a condition +**Goal:** We would like to get all plug pages and sorted by last modified time. -**Result:** Okay, this what we wanted but there are also information such as perm, type and lastModified that we don't want to show in the page +**Result:** Okay, this what we wanted but there are also information such as perm, type and lastModified that we don't need. |name |lastModified |perm|type|uri |repo |author | |--|--|--|--|--|--|--| -|πŸ”Œ Query |1659180816719|rw|plug|core:query |https://github.com/silverbulletmd/silverbullet |Silver Bullet Authors| +|πŸ”Œ Query |1659181148142|rw|plug|core:query |https://github.com/silverbulletmd/silverbullet |Silver Bullet Authors| |πŸ”Œ Mattermost|1659111156000|rw|plug|github:silverbulletmd/silverbullet-mattermost/mattermost.plug.json|https://github.com/silverbulletmd/silverbullet-mattermost|Zef Hemel | |πŸ”Œ Backlinks |1659108035000|rw|plug|ghr:Willyfrog/silverbullet-backlinks |https://github.com/Willyfrog/silverbullet-backlinks |Guillermo VayΓ‘ | |πŸ”Œ Ghost |1659108035000|rw|plug|github:silverbulletmd/silverbullet-ghost/ghost.plug.json |https://github.com/silverbulletmd/silverbullet-ghost |Zef Hemel | @@ -121,9 +125,9 @@ For the sake of simplicity, we will use `page` data source and limit the results #### 5.3 Query to select only certain fields -**Goal:** We would like to get all plug pages, select only `name` and `uri` column and sort by last modified time and +**Goal:** We would like to get all plug pages, select only `name`, `author` and `repo` columns and sort by last modified time. -**Result:** Okay, this is much better. However, I believe this needs a touch from a visual perspective +**Result:** Okay, this is much better. However, I believe this needs a touch from a visual perspective. |name |author |repo | @@ -137,9 +141,9 @@ For the sake of simplicity, we will use `page` data source and limit the results #### 5.4 Display the data in a format defined by a template -**Goal:** We would like to display the data from 5.3 in a nice format using bullet points with links to Plug pages, with author name and link to their GitHub repo. +**Goal:** We would like to display the data from step 5.3 in a nice format using bullet points with links to Plug pages, with author name and link to their GitHub repo. -**Result:** Here you go this is the result we would like to achieve πŸŽ‰. Did you see how I used `render` and `template/plug` in a query? πŸš€ +**Result:** Here you go. This is the result we would like to achieve πŸŽ‰. Did you see how I used `render` and `template/plug` in a query? πŸš€ * [[πŸ”Œ Query]] by **Silver Bullet Authors** ([repo](https://github.com/silverbulletmd/silverbullet)) @@ -147,4 +151,15 @@ For the sake of simplicity, we will use `page` data source and limit the results * [[πŸ”Œ Backlinks]] by **Guillermo VayΓ‘** ([repo](https://github.com/Willyfrog/silverbullet-backlinks)) * [[πŸ”Œ Ghost]] by **Zef Hemel** ([repo](https://github.com/silverbulletmd/silverbullet-ghost)) * [[πŸ”Œ Git]] by **Zef Hemel** ([repo](https://github.com/silverbulletmd/silverbullet-github)) - \ No newline at end of file + + +PS: You don't need select only certain fields to use templates. Templates are smart enough to get only the information needed to render the data. +Therefore, following queries are same in terms of end result when using the templates. + +```yaml + +``` + +```yaml + +``` From 4be859c8105196beb1db6cd56745239dbf7b2f36 Mon Sep 17 00:00:00 2001 From: "Sinan Sonmez (Chaush)" Date: Sat, 30 Jul 2022 15:42:25 +0000 Subject: [PATCH 11/11] adress PR review --- website/πŸ”Œ Query.md | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/website/πŸ”Œ Query.md b/website/πŸ”Œ Query.md index 4392bfd4..f6af57e8 100644 --- a/website/πŸ”Œ Query.md +++ b/website/πŸ”Œ Query.md @@ -6,15 +6,15 @@ author: Silver Bullet Authors ``` ### 1. What? -The query plug is a built-in plug implementing the `` mechanism. You can use query plug to automatically receive information from your notes. +The query plug is a built-in plug implementing the `` mechanism. You can use query plug to automatically receive information from your pages. ### 2. Syntax 1. _start with_: `` 2. _end with_: `` 3. _write your query_: replace `[QUERY GOES HERE]` with any query you want using options below -4. _available query options_: Usage of options is similar to general query language except special render option. Render option is to use display the data in a format that you created in a separate template +4. _available query options_: Usage of options is similar to SQL except special `render` option. Render option is to use display the data in a format that you created in a separate template * `where` - * `order` + * `order by` * `limit` * `select` * `render` @@ -27,7 +27,7 @@ After writing the query, there are three options: * Use shortcut: hit **Alt-q** (Windows, Linux) or **Option-q** (Mac) * Go to another page and come back to the page where query is located -After using one of the options, the data will be displayed. +After using one of the options, the β€œbody” of the query is replaced with the new results of the query data will be displayed. ### 4. Data sources Available data sources can be categorized as: @@ -37,18 +37,16 @@ Available data sources can be categorized as: Best part about data sources: there is an auto completion. πŸŽ‰ -Start writing ` 20 and country = "Italy" --> |name|age|city |country|page |pos | |----|--|-----|-----|---------------|----| -|John|50|Milan|Italy|Test Data Query|0 | -|Jane|53|Rome |Italy|Test Data Query|46 | -|John|50|Milan|Italy|πŸ”Œ Query |2148| -|Jane|53|Rome |Italy|πŸ”Œ Query |2194| +|John|50|Milan|Italy|πŸ”Œ Query |2198| +|Jane|53|Rome |Italy|πŸ”Œ Query |2244| -#### 4.3 Plugs’ data sources +#### 4.2 Plugs’ data sources Certain plugs can also provide special data sources to query a certain data. Some examples are * [[πŸ”Œ Github]] provides `gh-pull` to query PRs for selected repo * [[πŸ”Œ Mattermost]] provides `mm-saved` to fetch (by default 15) saved posts in Mattermost @@ -96,10 +91,10 @@ For the sake of simplicity, we will use `page` data source and limit the results |name |lastModified |perm|tags |type|uri |repo |author | |--|--|--|--|--|--|--|--| -|index |1659178324609|rw|undefined|undefined|undefined |undefined |undefined | +|index |1659178324000|rw|undefined|undefined|undefined |undefined |undefined | |Mattermost Plugin|1659108035000|rw|undefined|undefined|undefined |undefined |undefined | |PLUGS |1659108634000|rw|undefined|undefined|undefined |undefined |undefined | -|Test Data Query |1659179547936|rw|undefined|undefined|undefined |undefined |undefined | +|Test Data Query |1659179547000|rw|undefined|undefined|undefined |undefined |undefined | |template/plug |1659108035000|rw|undefined|undefined|undefined |undefined |undefined | |template/tasks |1659108035000|rw|#each|undefined|undefined |undefined |undefined | |πŸ’‘ Inspiration |1659108035000|rw|undefined|undefined|undefined |undefined |undefined | @@ -116,7 +111,7 @@ For the sake of simplicity, we will use `page` data source and limit the results |name |lastModified |perm|type|uri |repo |author | |--|--|--|--|--|--|--| -|πŸ”Œ Query |1659181148142|rw|plug|core:query |https://github.com/silverbulletmd/silverbullet |Silver Bullet Authors| +|πŸ”Œ Query |1659194185345|rw|plug|core:query |https://github.com/silverbulletmd/silverbullet |Silver Bullet Authors| |πŸ”Œ Mattermost|1659111156000|rw|plug|github:silverbulletmd/silverbullet-mattermost/mattermost.plug.json|https://github.com/silverbulletmd/silverbullet-mattermost|Zef Hemel | |πŸ”Œ Backlinks |1659108035000|rw|plug|ghr:Willyfrog/silverbullet-backlinks |https://github.com/Willyfrog/silverbullet-backlinks |Guillermo VayΓ‘ | |πŸ”Œ Ghost |1659108035000|rw|plug|github:silverbulletmd/silverbullet-ghost/ghost.plug.json |https://github.com/silverbulletmd/silverbullet-ghost |Zef Hemel |