Open eduardosada opened 2 years ago
Just wrap your condition in an array.
<script setup lang="ts">
import type { QueryBuilderParams } from '@nuxt/content/dist/runtime/types';
let query: QueryBuilderParams = {
where: [{ _draft: { $eq: false } }],
};
</script>
The where
field in the QueryBuilderParams
is an array. We have done this especially to simplify joining multiple conditions.
Thanks @farnabaz
Try it yourself:
https://stackblitz.com/edit/nuxt-starter-xzi3df?file=pages%2Findex.vue
If you put where: [{ _draft: { $eq: false } }],
doesn't throw a type error but the filter doesn't work.
If you put where: { _draft: { $eq: false } },
the filter is working but the type check is failing.
I see, thanks for clarifying. I've missed that you are using ContentList
.
Types should update to fix this.
Environment
Linux
v16.14.2
3.0.0-rc.9
0.5.2
npm@7.17.0
vite
target
,typescript
,modules
,runtimeConfig
@nuxt/content@2.1.0
Build Modules:
-
Reproduction
https://stackblitz.com/edit/nuxt-starter-eqgbnv?file=pages%2Findex.vue
Describe the bug
The
where
property on TypeQueryBuilderParams
is incorrectly marked as an array.Consider the following code:
Running
nuxi typecheck
will throw an error:Additional context
No response
Logs
No response