Jitendra
Jitendra
DTDrizzle Team
Created by AndréLB on 8/17/2024 in #help
Joins with results in arrays
Yea I would like something like this too. I am currently using promise.all
139 replies
DTDrizzle Team
Created by Pim de Wit on 8/2/2024 in #help
`drizzle-kit migrate` errors
Can you share drizzle.config.ts file??
3 replies
DTDrizzle Team
Created by Jitendra on 4/15/2024 in #help
where clause when using 'with' in relational mode
Again thank you for support. Really Appreciate it
19 replies
DTDrizzle Team
Created by Jitendra on 4/15/2024 in #help
where clause when using 'with' in relational mode
Just a little correction the courseMember.courseId will be first arguement
inArray(
courseMember.courseId,
db
.select({ id: course.id })
.from(course)
.where(like(course.title, `%${search ? search : ""}%`))
)
inArray(
courseMember.courseId,
db
.select({ id: course.id })
.from(course)
.where(like(course.title, `%${search ? search : ""}%`))
)
19 replies
DTDrizzle Team
Created by Jitendra on 4/15/2024 in #help
where clause when using 'with' in relational mode
I will try to explore more inArray thing.
19 replies
DTDrizzle Team
Created by Jitendra on 4/15/2024 in #help
where clause when using 'with' in relational mode
Thank you so much Angelelz. This works for me. Also thanks for suggestion for having title in the join table.
19 replies
DTDrizzle Team
Created by Jitendra on 4/15/2024 in #help
where clause when using 'with' in relational mode
Thank you so much Angelelz for the reply. I want all the courses of the particular member. I am able to achieve this
const memberCourses = await db.query.courseMember.findMany({
where: eq(courseMember.userId, currentUser.userId),
with: {
course: {
columns: {
id: true,
title: true,
slug: true,
},
},
},
});
const memberCourses = await db.query.courseMember.findMany({
where: eq(courseMember.userId, currentUser.userId),
with: {
course: {
columns: {
id: true,
title: true,
slug: true,
},
},
},
});
Response:
memberCourses [
{
courseId: 'omfwymi9a6ymi3qkdvaqohoy',
userId: 'w013zk4be8rnw4wzdmmuoc6x',
role: 'owner',
course: {
id: 'omfwymi9a6ymi3qkdvaqohoy',
title: 'React Beginners Course',
slug: 'react-beginners-course'
}
},
{
courseId: 'mq8gu6j222h9znq72ipj2f8w',
userId: 'w013zk4be8rnw4wzdmmuoc6x',
role: 'owner',
course: {
id: 'mq8gu6j222h9znq72ipj2f8w',
title: 'React UI Library',
slug: 'react-ui-library'
}
},
{
courseId: 'mzj6i75a3m4ofnnsvyoc66xo',
userId: 'w013zk4be8rnw4wzdmmuoc6x',
role: 'owner',
course: {
id: 'mzj6i75a3m4ofnnsvyoc66xo',
title: 'Advanced UI',
slug: 'advanced-ui'
}
}
]
memberCourses [
{
courseId: 'omfwymi9a6ymi3qkdvaqohoy',
userId: 'w013zk4be8rnw4wzdmmuoc6x',
role: 'owner',
course: {
id: 'omfwymi9a6ymi3qkdvaqohoy',
title: 'React Beginners Course',
slug: 'react-beginners-course'
}
},
{
courseId: 'mq8gu6j222h9znq72ipj2f8w',
userId: 'w013zk4be8rnw4wzdmmuoc6x',
role: 'owner',
course: {
id: 'mq8gu6j222h9znq72ipj2f8w',
title: 'React UI Library',
slug: 'react-ui-library'
}
},
{
courseId: 'mzj6i75a3m4ofnnsvyoc66xo',
userId: 'w013zk4be8rnw4wzdmmuoc6x',
role: 'owner',
course: {
id: 'mzj6i75a3m4ofnnsvyoc66xo',
title: 'Advanced UI',
slug: 'advanced-ui'
}
}
]
But when I type the search query I want only matching course name so I want to use the where clause with like..
19 replies
DTDrizzle Team
Created by Jitendra on 4/15/2024 in #help
where clause when using 'with' in relational mode
Sorry for tagging but I couldn't find any help @Angelelz @Dan Kochetov
19 replies
DTDrizzle Team
Created by Jitendra on 4/15/2024 in #help
where clause when using 'with' in relational mode
bump.. Anyone please
19 replies
DTDrizzle Team
Created by Jitendra on 4/15/2024 in #help
where clause when using 'with' in relational mode
basically it's many to many relationship. I have seen example of one to many in the docs using where clause in with. Even one to many works for me But in this case I am not able to use the where clause
19 replies
DTDrizzle Team
Created by Thig on 6/7/2023 in #help
Refetching?
I faced this similar problem too. I though it's drizzle but it was next.js export const revalidate = 0; export const dynamic = "force-dynamic";
10 replies