nuxt content order by deep value
like
but it won't work cuz
props.date
isn't keyof Collection
4 Replies
Hi @envizar. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
I'm sorry, but the knowledge sources do not provide any information indicating that Nuxt Content's queryCollection supports ordering by deep (nested) values such as props.date using the order method. The documented usage and API examples only show ordering by top-level fields that are direct keys of the collection schema, e.g., order('date', 'DESC') where date is a direct property of the collection item, not a nested property like props.date Query Utils: order.
Attempting to use a nested path like 'props.date' will not work because the order method expects a key of the collection, not a deep property. The documentation does not mention any workaround or support for ordering by nested fields.
If you need to order by a nested value, you may need to flatten your schema or add a top-level field for sorting purposes. If you require more advanced sorting, you might need to handle it manually after fetching the data.
If you need further clarification, you may want to check for updates in the official documentation or open an issue with the Nuxt Content team.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@515829500945367078> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
What does your collection definition look like?
something like
then I use that schema