How do you query z.array()
fields (e.g. tags) in the latest nuxt-content module (v3.alpha.8)
#2955
Unanswered
humblemodulo
asked this question in
Q&A
Replies: 1 comment
-
I have a similar need for filtering tags like this: let query = queryCollection('content').where('tags', 'LIKE', `%${tag}%`) if filter multiple: let query = queryCollection('content')
if (filter_tags.length) {
filter_tags.forEach(tag => {
query = query.where('tags', 'LIKE', `%${tag}%`)
})
}
query.order('date', 'DESC').all() Because I found that the 'tags' field in the SQLite database is merely of type Text. so, it can only be filtered using LIKE... if you have a better way, please tell me 😀 |
Beta Was this translation helpful? Give feedback.
0 replies
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
In the previous version of nuxt-content (v2) I would simply query tags like so:
However there is no
contains
in v3, and the logic forIN
seems to require the reverse operation. I've triedLIKE
and that doesn't work either.Definitely need to know the best way to find values in z.array() field types.
As it stands, I'm forced to retrieve all, then run JS
.filter()
on the results. Quite inefficient.Beta Was this translation helpful? Give feedback.
All reactions