Context entities in a query
First steps in Wasp-lang coming from PHP
Trying to get to know Wasp-lang I'm working on a job list, where users can post jobs. So in entity Job i have userId and User as relation.
Passing the user entity with the job in the getJobs query
query getJobs {
fn: import { getJobs } from "@src/server/queries.js",
entities: [Job, User]
}
I tried to inlcude the user but I'm not sure how I can use this in a result. I can show the job.userId but not the related user object for example user.username.
export const getJobs: GetJobs<void, Job[]> = async (args, context) => {
return context.entities.Job.findMany({
orderBy: { id: 'asc' },
include: {
user: true,
}
})
Trying to get to know Wasp-lang I'm working on a job list, where users can post jobs. So in entity Job i have userId and User as relation.
Passing the user entity with the job in the getJobs query
query getJobs {
fn: import { getJobs } from "@src/server/queries.js",
entities: [Job, User]
}
I tried to inlcude the user but I'm not sure how I can use this in a result. I can show the job.userId but not the related user object for example user.username.
export const getJobs: GetJobs<void, Job[]> = async (args, context) => {
return context.entities.Job.findMany({
orderBy: { id: 'asc' },
include: {
user: true,
}
})

