kapa.ai
kapa.ai
NNuxt
Created by Whitey on 2/1/2025 in #❓・help
nuxt/content queryCollection not returning results when using .order()
5 replies
NNuxt
Created by Whitey on 2/1/2025 in #❓・help
nuxt/content queryCollection not returning results when using .order()
4. Check for typos: Ensure that the field name in your order() method exactly matches the field name in your frontmatter and schema definition. 5. Verify collection name: Make sure that 'posts' is the correct name of your collection as defined in your content.config.ts file. If none of these solutions work, you might be encountering a bug in Nuxt Content. In that case, it would be helpful to create a minimal reproduction of the issue and report it as a bug to the Nuxt Content GitHub repository. Remember, Nuxt Content v3 uses a SQL-based storage system, which is different from previous versions. This change might affect how certain operations, like ordering, are handled. If you continue to face issues, consider opening a GitHub Discussion or seeking help from the Nuxt community as suggested in the Getting Help guide. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
5 replies
NNuxt
Created by Whitey on 2/1/2025 in #❓・help
nuxt/content queryCollection not returning results when using .order()
---------------------- Based on the information provided in your question and the knowledge sources available, it appears you're encountering an issue with the order() method in Nuxt Content v3. Let's address this problem step by step. The error message you're seeing suggests that the database cannot find a column named "date". This typically happens when the field you're trying to order by is not properly defined or recognized in your content schema. Here are a few potential solutions and things to check: 1. Define your collection schema: Make sure you have properly defined your collection schema in your content.config.ts file. The date field should be explicitly defined as a date type. Here's an example:
import { defineCollection, defineContentConfig, z } from '@nuxt/content'

export default defineContentConfig({
collections: {
posts: defineCollection({
type: 'page',
schema: z.object({
title: z.string(),
date: z.date()
})
})
}
})

import { defineCollection, defineContentConfig, z } from '@nuxt/content'

export default defineContentConfig({
collections: {
posts: defineCollection({
type: 'page',
schema: z.object({
title: z.string(),
date: z.date()
})
})
}
})

Define your collection schema to ensure all fields are properly recognized. 2. Check the date format: Ensure that the date in your frontmatter is in a format that can be parsed as a valid date. The format you're using (2025-01-01) should be correct, but double-check to make sure there are no typos. 3. Use createdAt or updatedAt: If defining the schema doesn't solve the issue, you could try using the built-in createdAt or updatedAt fields for ordering, which are automatically generated by Nuxt Content:
return queryCollection('posts')
.order('createdAt', 'DESC')
.select('path', 'title', 'date')
.all()

return queryCollection('posts')
.order('createdAt', 'DESC')
.select('path', 'title', 'date')
.all()

5 replies
NNuxt
Created by Whitey on 2/1/2025 in #❓・help
nuxt/content queryCollection not returning results when using .order()
Hi @Whitey. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
5 replies
NNuxt
Created by Serhii Chernenko on 2/1/2025 in #❓・help
@tus/server production build error
12 replies
NNuxt
Created by Serhii Chernenko on 2/1/2025 in #❓・help
@tus/server production build error
However, as mentioned in the Github Issue #30749, this workaround should be wrapped in a $development condition to avoid affecting production builds. 6. Check for circular dependencies: Although not directly mentioned in the error, circular dependencies can sometimes cause similar issues. You can use tools like dpdm to check for circular dependencies in your project. If the problem persists after trying these suggestions, it would be helpful to create a minimal reproduction of the issue and share it with the Nuxt community or open an issue on the Nuxt GitHub repository for more specific assistance. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
12 replies
NNuxt
Created by Serhii Chernenko on 2/1/2025 in #❓・help
@tus/server production build error
---------------------- I apologize for the confusion in my previous response. Let me address the specific error message you provided: "[nitro] [uncaughtException] Class extends value [object Module] is not a constructor or null" This error message is indeed related to Nuxt and its Nitro server. Based on the knowledge sources provided, I can offer some insights and potential solutions: 1. Version compatibility: This issue might be related to a specific Nuxt version. According to the Github Issue #29354, a similar error was reported and resolved in Nuxt version 3.15.3. If you're using an older version, consider upgrading to the latest stable release of Nuxt. 2. Server-side rendering (SSR) issues: The error suggests a problem with class extension, which could be related to how modules are being loaded or used in the server-side context. This is particularly relevant if you're using server components or SSR features. 3. Module compatibility: Ensure that all your modules, including any custom ones, are compatible with the version of Nuxt you're using. Some modules might need to be updated or configured differently for production builds. 4. Build configuration: Check your nuxt.config.ts file for any settings that might affect the production build process. Pay special attention to any custom Vite or webpack configurations if you have them. 5. Workaround for development: If you're encountering this issue in the development environment, you might try adding the following to your nuxt.config.ts file as a temporary workaround:
export default defineNuxtConfig({
vite: {
ssr: {
noExternal: ['moment-timezone'] // or other problematic modules
}
}
})

export default defineNuxtConfig({
vite: {
ssr: {
noExternal: ['moment-timezone'] // or other problematic modules
}
}
})

12 replies
NNuxt
Created by Serhii Chernenko on 2/1/2025 in #❓・help
@tus/server production build error
Let me check the knowledge base for you again. One moment! :books:
12 replies
NNuxt
Created by Serhii Chernenko on 2/1/2025 in #❓・help
@tus/server production build error
12 replies
NNuxt
Created by Serhii Chernenko on 2/1/2025 in #❓・help
@tus/server production build error
Remember, for more accurate assistance, it would be helpful to have more details about your specific setup, Nuxt version, and the relevant parts of your code where you're using @tus/server. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
12 replies
NNuxt
Created by Serhii Chernenko on 2/1/2025 in #❓・help
@tus/server production build error
---------------------- Based on the information provided in the knowledge sources, I don't have enough specific details to directly address the "@tus/server production build error" you're encountering. However, I can provide some general insights about Nuxt and error handling that might be relevant: The error message you're seeing ("Class extends value [object Module] is not a constructor or null") suggests there might be an issue with how a module is being imported or used in your Nuxt application. This type of error can sometimes occur when there's a mismatch between CommonJS and ES modules. Here are a few things you could consider: 1. Check your Nuxt version: Make sure you're using the latest stable version of Nuxt, as some issues might have been resolved in recent updates. 2. Review your module imports: Ensure that all your imports, especially for @tus/server, are correctly formatted and compatible with your Nuxt setup. 3. Examine your build configuration: The error is occurring during the production build, so there might be an issue specific to the build process. 4. Look into Nuxt's error handling: Nuxt provides various ways to handle errors, which might help you debug this issue. You can refer to the Error Handling documentation for more information. 5. Check for compatibility: Ensure that @tus/server is compatible with your Nuxt version and setup. If the problem persists, you might want to create a minimal reproduction of the issue and seek help from the Nuxt community or the maintainers of the @tus/server package.
12 replies
NNuxt
Created by Serhii Chernenko on 2/1/2025 in #❓・help
@tus/server production build error
Hi @Serhii Chernenko. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
12 replies
WWasp
Created by High on 2/1/2025 in #🙋questions
Query with multiple entities
Sorry @High, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
10 replies
WWasp
Created by High on 2/1/2025 in #🙋questions
Query with multiple entities
Thank you for bringing this up. It's a valuable point that highlights an area where Wasp is still evolving. The team is committed to improving this aspect of the framework to provide a more seamless full-stack TypeScript experience in the future. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
10 replies
WWasp
Created by High on 2/1/2025 in #🙋questions
Query with multiple entities
---------------------- You're right, and I apologize for not addressing the frontend typing in my previous answer. Your observation is correct and highlights an important aspect of working with Wasp queries that involve multiple entities. Currently, Wasp doesn't automatically propagate the full type information from the backend to the frontend for queries involving multiple entities or complex relationships. This is a known limitation that the Wasp team is aware of and working to improve. As a workaround, you indeed need to manually specify the type on the frontend as well. Your approach is correct:
const GameCard = ({ game }: { game: (Game & { players: User[] })}) => {
// ...
}
const GameCard = ({ game }: { game: (Game & { players: User[] })}) => {
// ...
}
This issue is related to the full-stack type safety feature that Wasp is aiming to provide. While Wasp does offer some level of automatic type inference, there are still cases where manual type annotations are necessary, especially for more complex data structures. The Wasp team is actively working on improving this situation. There's an ongoing effort to enhance full-stack type support, as mentioned in the GitHub issue #910. The goal is to have users define everything about a Query once, and then have Wasp automatically handle the typing everywhere else, including the frontend. In the meantime, the approach you're using is the recommended way to handle this situation. By explicitly typing the props in your frontend components, you ensure type safety and enable proper IntelliSense in your IDE.
10 replies
WWasp
Created by High on 2/1/2025 in #🙋questions
Query with multiple entities
Let me check the knowledge base for you again. One moment! :books:
10 replies
WWasp
Created by High on 2/1/2025 in #🙋questions
Query with multiple entities
Sorry @High, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
10 replies
WWasp
Created by High on 2/1/2025 in #🙋questions
Query with multiple entities
By specifying the return type more precisely, you should resolve the TypeScript errors and get proper intellisense for the included players property. It's worth noting that the Wasp team is aware that this can be cumbersome and is working on improvements. There's an open issue #1884 to automatically infer the correct type without requiring such complex type annotations. For now, this approach should solve your immediate problem and allow you to work with multiple entities in your query while maintaining type safety. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
10 replies
WWasp
Created by High on 2/1/2025 in #🙋questions
Query with multiple entities
---------------------- To answer your question about working with multiple entities in a Wasp query and resolving TypeScript issues, let's look at the relevant information from the knowledge sources. You're on the right track with specifying multiple entities in your query definition. However, the TypeScript issue you're encountering is related to how you're annotating the return type of your query function. Let's break it down: 1. Query Definition: Your query definition in main.wasp looks correct:
query getActiveGames {
fn: import { getActiveGames } from "@src/server/queries/game",
entities: [Game, User]
}
query getActiveGames {
fn: import { getActiveGames } from "@src/server/queries/game",
entities: [Game, User]
}
2. Query Implementation: The issue lies in how you're typing the query implementation. When you include related entities (like players in this case), you need to reflect that in the return type. Here's how you can fix it:
import { GetActiveGames } from 'wasp/server/operations'
import { Game, User } from 'wasp/entities'

export const getActiveGames: GetActiveGames<void, (Game & { players: User[] })[]> = async (
_args,
context
) => {
return context.entities.Game.findMany({
where: { isActive: true },
include: { players: true }
})
}
import { GetActiveGames } from 'wasp/server/operations'
import { Game, User } from 'wasp/entities'

export const getActiveGames: GetActiveGames<void, (Game & { players: User[] })[]> = async (
_args,
context
) => {
return context.entities.Game.findMany({
where: { isActive: true },
include: { players: true }
})
}
The key change here is in the return type annotation. Instead of just Game[], we're using (Game & { players: User[] })[]. This tells TypeScript that we're returning an array of Game objects, each of which includes a players property that is an array of User objects. This approach is described in the Wasp documentation on Queries and further elaborated in a Discord support thread.
10 replies
WWasp
Created by High on 2/1/2025 in #🙋questions
Query with multiple entities
Hi @High. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
10 replies