smoke
smoke
Explore posts from servers
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
I assume that it is currently not possible to use that ‘or’ condition as in my previous query, using the new relations module?
40 replies
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
I'll try that out, thanks a lot!
40 replies
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
I see! That will definitely work
40 replies
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
That's why I had a direct ownerId column on the teams table.
40 replies
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
No worries at all, I understand! That will definitely work for me. I thought of that approach first but that would technically allow multiple users to be an owner of a team but I think that will be fine.
40 replies
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
Thanks a lot, I'll just go with that approach. I appreciate it!
40 replies
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
Yes I understand what you mean, that does make more sense honestly and that would also improve the performance.
40 replies
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
Where would in come from? Or do you mean inArray? Because I can't use team.teamMembers with inArray, that gives me a type error.
40 replies
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
@Andrii Sherman Did you have time to take a look into this issue? I'd appreciate it!
40 replies
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
I want to fetch all the teams for a specific userId, whether they are connected through the direct ownerId column or through the team_members join table.
40 replies
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
If that’s possible
40 replies
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
Yes exactly!
40 replies
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
Of course no worries at all. I appreciate it!
40 replies
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
For example, this is how I currently get all teams from an user whether they are the owner or connected through the join table:
const userId = "foo";

.leftJoin(teamMembers, eq(team.id, teamMembers.teamId))
.where(or(eq(team.ownerId, userId), eq(teamMembers.userId, userId)))
const userId = "foo";

.leftJoin(teamMembers, eq(team.id, teamMembers.teamId))
.where(or(eq(team.ownerId, userId), eq(teamMembers.userId, userId)))
But I would like to use the new relations module for this.
40 replies
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
Anyone that could help with this? I’d really appreciate it!
40 replies
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
Because I can’t access teamMembers under the team property, like a deep condition.
40 replies
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
I just thought of a similar method as the some property from Prisma, not too sure though
40 replies
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
I understand! But is that the correct way of checking if that specific userId is connected through the join table?
40 replies
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
I expect something like this, similar to the some property from Prisma, but this currently does not exist in the relational queries:
const userId = "foo";

await db.query.teams.findMany({
where: (team, { eq, or }) => or(
eq(team.ownerId, userId),
in(team.teamMembers, userId)
),
});
const userId = "foo";

await db.query.teams.findMany({
where: (team, { eq, or }) => or(
eq(team.ownerId, userId),
in(team.teamMembers, userId)
),
});
40 replies
DTDrizzle Team
Created by smoke on 5/20/2023 in #help
Relations module - or condition
Anyone that could help me out with this? Especially because this is some ‘or’ condition, not quite sure
40 replies