Skip to content

Commit b3d2cfb

Browse files
committed
docs: generated SQL in queryCollection conditions
close #3333
1 parent f01256a commit b3d2cfb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

docs/content/docs/4.utils/1.query-collection.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,12 @@ const route = useRoute()
103103
const { data } = await useAsyncData(route.path, () => {
104104
return queryCollection('docs')
105105
.where('date', '<', '2024-04-04')
106+
.where('category', '=', 'news')
106107
.all()
107108
})
109+
110+
// Generated SQL
111+
// SELECT * FROM docs WHERE date < '2024-04-04' AND category = 'news'
108112
```
109113

110114
### `andWhere(groupFactory: QueryGroupFunction<Collection>)`
@@ -121,6 +125,9 @@ const { data } = await useAsyncData('recent-docs', () => {
121125
.andWhere(query => query.where('date', '>', '2024-01-01').where('category', '=', 'news'))
122126
.all()
123127
})
128+
129+
// Generated SQL
130+
// SELECT * FROM docs WHERE published = true AND (date > '2024-01-01' AND category = 'news')
124131
```
125132

126133
### `orWhere(groupFactory: QueryGroupFunction<Collection>)`
@@ -137,6 +144,9 @@ const { data } = await useAsyncData('featured-docs', () => {
137144
.orWhere(query => query.where('featured', '=', true).where('priority', '>', 5))
138145
.all()
139146
})
147+
148+
// Generated SQL
149+
// SELECT * FROM docs WHERE published = true AND (featured = true OR priority > 5)
140150
```
141151

142152
### `order(field: keyof Collection, direction: 'ASC' | 'DESC')`

0 commit comments

Comments
 (0)