nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.12k stars 623 forks source link

`sortBy` doesn't sort the query result #1064

Closed smarroufin closed 2 years ago

smarroufin commented 2 years ago

Environment

Reproduction

Let's say we have blog posts with a date in the front matter: 1.article-1.md

---
date: 2021-09-10
---

2.article-2.md

---
date: 2022-01-01
---

queryContent('/resources/blog').where({ $not: { slug: { $in: ['/resources/blog'] } } }).sortBy('date', 'desc').find()

Describe the bug

The order should be affected by the sortBy. But it isn't.

Additional context

No response

Logs

No response

pidgpowell commented 2 years ago

@farnabaz thank you! i can now sort!!

farnabaz commented 2 years ago

Thanks for explanation @smarroufin. This is fixed in #1069 and it should works fine in latest version.

JenuelDev commented 2 years ago

Property 'sortBy' does not exist on type 'QueryBuilder'. Did you mean 'sort'?ts(2551)

farnabaz commented 2 years ago

@BroJenuel Yes, you can use sort to order results. Check out sort docs

PuxianAlHazred commented 1 year ago

@farnabaz thank you! i can now sort!!

thx you for ?