How do you query `z.array()` fields (e.g. tags) in the latest content module (v3.alpha.8)

In the previous version of nuxt-content (v2) I would simply query tags like so:
.where({ tags: { $contains: tagSlug } })
.where({ tags: { $contains: tagSlug } })
However there is no contains in v3, and the logic for in seems to require the reverse operation. I've tried like and that doesn't work either.
Definitely need to know the best way to match values in z.array() field types.
7 Replies
kapa.ai
kapa.ai3w ago
Hi @humblemodulo. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I apologize, but the knowledge sources provided do not contain specific information about querying z.array() fields or using $contains in Nuxt Content v3.alpha.8. The information available is mostly about Nuxt Content v1 and v2, with some details about v2 to v3 migration, but it doesn't address your specific question about querying array fields in v3.alpha.8. However, based on the general information about querying in Nuxt Content v2 and v3, I can suggest that you might want to check the latest documentation for Nuxt Content v3 for the most up-to-date querying methods. The querying syntax has changed between versions, and it's possible that the method for querying array fields has also been updated. If you can't find the information in the official documentation, you might want to: 1. Check the GitHub repository for Nuxt Content for any recent updates or discussions about querying array fields. 2. Ask this specific question in the Nuxt community forums or Discord channel, where you might get more current information from other developers using the latest alpha version. I apologize that I couldn't provide a more specific answer based on the knowledge sources available. The rapid development of Nuxt Content means that the most current information might not be reflected in the provided documentation snippets. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3w ago
<@924898811162288160> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
humblemodulo
humblemoduloOP2w ago
Anyone? @manniL ?
manniL
manniL2w ago
@humblemodulo does .where({ tags: { $in: tagSlug } }) work? (ah nvm, you tried that already)
manniL
manniL2w ago
manniL
manniL2w ago
hmm - might be worth raising an issue 👍 You could probably loop and do an orWhere!
humblemodulo
humblemoduloOP2w ago
Yeah, currently I'm doing it manually. Query all, then JS filter. 🫠 I opened discussion but not an issue. Just logged off for the day, but I'll log something tomorrow. Thanks!

Did you find this page helpful?