Skip to content

Commit a3d2c4b

Browse files
authored
Add documentation for logical operators in Query Builder (#305)
- Introduced OR and NOT OR operators for complex queries. - Detailed steps for creating and managing OR/NOT OR branches. - Provided practical examples for using these operators in queries.
1 parent f8bd81d commit a3d2c4b

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

docs/query-builder.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,68 @@ Some relationships have a `target` field that supports the following options:
8989
- `{this page}` - matches the page in which the query is run
9090
- `{current user}` - matches the current user
9191

92+
### Logical Operators (OR and NOT OR Branches)
93+
94+
Query Builder supports advanced logical operators that allow you to create complex queries with multiple branches. These operators enable you to build sophisticated queries that can handle multiple scenarios or exclude specific conditions.
95+
96+
**OR Operator**: Returns results that match **any** of the specified branches. Think of it as "this OR that OR the other thing."
97+
98+
**NOT OR Operator**: Returns results that do **not** match **any** of the specified branches. Think of it as "not this AND not that AND not the other thing."
99+
100+
#### Creating OR/NOT OR Branches
101+
102+
1. **Add a new condition** to your query
103+
2. **Change the condition type** from the dropdown menu (default is "clause")
104+
3. **Select "or" or "not or"** from the options
105+
4. **Click "Edit"** to manage the branches
106+
107+
![](https://firebasestorage.googleapis.com/v0/b/firescript-577a2.appspot.com/o/imgs%2Fapp%2Froamjs%2FEqF8c_sT4p.png?alt=media&token=156e8915-d46e-4847-8ce6-bac7c03dbc3b)
108+
109+
#### Managing Branches
110+
111+
When you create an OR or NOT OR condition, you'll see a tabbed interface that allows you to manage multiple branches:
112+
113+
- **Each tab represents a branch** (numbered 1, 2, 3, etc.)
114+
- **Each branch contains AND conditions** - all conditions within a branch must be true
115+
- **Branches are combined with OR logic** - any branch being true will return results
116+
- **Use "Add Branch"** to create additional branches
117+
- **Use "Add Condition"** to add more conditions within the current branch
118+
119+
#### Navigation Between Branches
120+
121+
- **Click on tabs** to switch between branches
122+
- **Use left/right arrow keys** to navigate between branches
123+
- **Use "Add Branch" button** to create new branches
124+
- **Use "Back" button** to return to the main query view
125+
126+
#### Practical Examples
127+
128+
**Example 1: OR Query - Finding Tasks by Multiple Statuses**
129+
130+
**Goal**: Find all tasks that are either "In Progress" OR "Pending Review"
131+
132+
1. Create a new condition
133+
2. Change type to "or"
134+
3. Click "Edit"
135+
4. In Branch 1: Add condition `node` `has attribute` `In Progress`
136+
5. Click "Add Branch"
137+
6. In Branch 2: Add condition `node` `has attribute` `Pending Review`
138+
139+
Returns all blocks that have either "In Progress" or "Pending Review" as attributes.
140+
141+
**Example 2: NOT OR Query - Excluding Multiple Categories**
142+
143+
**Goal**: Find all notes that are NOT about "Work" AND NOT about "Personal"
144+
145+
1. Create a new condition
146+
2. Change type to "not or"
147+
3. Click "Edit"
148+
4. In Branch 1: Add condition `node` `has attribute` `Work`
149+
5. Click "Add Branch"
150+
6. In Branch 2: Add condition `node` `has attribute` `Personal`
151+
152+
Returns all blocks that do NOT have "Work" as an attribute AND do NOT have "Personal" as an attribute.
153+
92154
## Selections
93155

94156
**Selections** specify what data from the blocks that match your conditions get returned. They determine the **columns** of the table. By default, the block text or page title is always returned and hyperlinked. Every selection is made up of two parts: the `label` and the `data`:

0 commit comments

Comments
 (0)