Skip to content

Commit c71c79b

Browse files
committed
fix(query): do not create empty where
1 parent 2602c07 commit c71c79b

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/runtime/server/api/navigation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default defineEventHandler(async (event) => {
1010

1111
// Read from cache if not preview and there is no query
1212
if (!isPreview(event) && Object.keys(query).length === 0) {
13-
const cache = cacheStorage.getItem('content-navigation.json')
13+
const cache = await cacheStorage.getItem('content-navigation.json')
1414
if (cache) {
1515
return cache
1616
}

src/runtime/utils/query.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,21 @@ export const getContentQuery = (event: CompatibilityEvent): QueryBuilderParams =
4040
query.without = query.without.split(',').map(s => s.trim())
4141
}
4242

43-
query.where = query.where || {}
43+
const where = query.where || {}
4444
// ?partial=true|false&draft=true|false&empty=true|false
4545
for (const key of ['draft', 'partial', 'empty']) {
4646
// ?partial=true|false
4747
if (query[key] && ['true', 'false'].includes(query[key])) {
48-
query.where[key] = query[key] === 'true'
48+
where[key] = query[key] === 'true'
4949
delete query[key]
5050
}
5151
}
52+
if (Object.keys(where).length > 0) {
53+
query.where = [where]
54+
} else {
55+
delete query.where
56+
}
57+
5258
// ?sortyBy=size:1
5359
if (query.sort) {
5460
query.sort = query.sort.split(',').map((s) => {

0 commit comments

Comments
 (0)