Whitey
Whitey
NNuxt
Created by Whitey on 2/1/2025 in #❓・help
nuxt/content queryCollection not returning results when using .order()
Hey all - I'm using Nuxt Content for the first time and loving it but I've hit an issue with trying to order results from the queryCollection(). Here's my .md file frontmatter:
---
title: test post 2
date: 2025-01-01
---

Test!
---
title: test post 2
date: 2025-01-01
---

Test!
and i'm trying to query it like so:
return queryCollection('posts')
.order('date', 'DESC')
.select('path', 'title', 'date')
.all()
return queryCollection('posts')
.order('date', 'DESC')
.select('path', 'title', 'date')
.all()
Which isn't returning any results. But, if I take away the date part:
return queryCollection('posts')
//.order('date', 'DESC')
.select('path', 'title', /*'date'*/)
.all()
return queryCollection('posts')
//.order('date', 'DESC')
.select('path', 'title', /*'date'*/)
.all()
it does successfully return the content. I do see the following error in the logs for npm run dev:
ERROR [nuxt] [request error] [unhandled] [500] no such column: "date" - should this be a string literal in single-quotes?
ERROR [nuxt] [request error] [unhandled] [500] no such column: "date" - should this be a string literal in single-quotes?
but I'm not really sure what to do with it. I've scanned the nuxt/content docs and AFAIK I'm doing this correctly. Any help is appreciated!
5 replies