2.0 KiB
2.0 KiB
type: plug
uri: core:query
repo: https://github.com/silverbulletmd/silverbullet
author: Silver Bullet Authors
1. What?
The query plug is a built-in plug implementing the <!-- #query -->
mechanism. You can use query plug to automatically receive information from your notes.
2. Syntax
- start with:
<!-- #query [QUERY GOES HERE] -->
- end with:
<!-- /query -->
- write your query: replace
[QUERY GOES HERE]
with any query you want using options below - 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
- 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
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.
4. Data sources
Available data sources can be categorized as
- Builtin data sources
- Data that can be inserted by users
- Plug’s data sourcer
Best part about data sources: there is an auto completion 🎉. Start writing <!— #query
, it will show you all available data sources.
4.1 Builtin data sources
page
: list of all pagestask
: list of all tasks created with[]
syntaxfull-text
: use it withwhere phrase = "SOME_TEXT"
. List of all pages whereSOME_TEXT
is mentioneditem
: list of ordered and unordered items such as bulleted liststags
: list of all hashtags used in all pageslink
: list of all pages giving a link to the page where query is written