san
san
NNuxt
Created by san on 3/8/2025 in #❓・help
Inconsistent queryCollection
Hello, we've coded up our first nuxt (v3.15.4) project. We've used nuxt for all sorts of SEO, gtag and more. Neat stuff!
We're having an issue with queryCollection. It's returning different array sizes across multiple calls for the same query:
const { data: posts } = await useAsyncData(() =>
queryCollection("content").order("date", "DESC").all()
);
let allPosts = cloneDeep(posts.value);
console.log("After query:", allPosts);
const { data: posts } = await useAsyncData(() =>
queryCollection("content").order("date", "DESC").all()
);
let allPosts = cloneDeep(posts.value);
console.log("After query:", allPosts);
Sometimes it returns an array of 1 element, sometimes 18. (18 is all.) feel like I'm missing something. Here's our content config.
export default defineContentConfig({
collections: {
content: defineCollection({
type: "page",
source: "**/*.md",
schema: z.object({
title: z.string(),
date: z.date(),
tagline: z.string(),
remoteURL: z.string(),
}),
}),
},
});
export default defineContentConfig({
collections: {
content: defineCollection({
type: "page",
source: "**/*.md",
schema: z.object({
title: z.string(),
date: z.date(),
tagline: z.string(),
remoteURL: z.string(),
}),
}),
},
});
Any ideas?
7 replies