! AlexNotTheLion
! AlexNotTheLion
Explore posts from servers
DTDrizzle Team
Created by ! AlexNotTheLion on 4/2/2024 in #help
friendship query that returns the other user object
updated! thank you kindly 🙂
8 replies
DTDrizzle Team
Created by ! AlexNotTheLion on 4/2/2024 in #help
friendship query that returns the other user object
const user = data.user;

const queryResult = await db
.select({
id: friendships.id,
status: friendships.status,
incoming: sql<boolean>`friendship.receiving_user = ${user.id}`,
profile: {
id: profiles.id,
username: profiles.username,
avatarUrl: profiles.avatarUrl
}
}).from(friendships).innerJoin(profiles, sql`(
friendship.sending_user != ${user.id}
AND friendship.sending_user = profile.id
) OR (
friendship.receiving_user != ${user.id}
AND friendship.receiving_user = profile.id
)`)
.where(sql`friendship.sending_user = ${user.id} OR friendship.receiving_user = ${user.id}`);
const user = data.user;

const queryResult = await db
.select({
id: friendships.id,
status: friendships.status,
incoming: sql<boolean>`friendship.receiving_user = ${user.id}`,
profile: {
id: profiles.id,
username: profiles.username,
avatarUrl: profiles.avatarUrl
}
}).from(friendships).innerJoin(profiles, sql`(
friendship.sending_user != ${user.id}
AND friendship.sending_user = profile.id
) OR (
friendship.receiving_user != ${user.id}
AND friendship.receiving_user = profile.id
)`)
.where(sql`friendship.sending_user = ${user.id} OR friendship.receiving_user = ${user.id}`);
8 replies
DTDrizzle Team
Created by ! AlexNotTheLion on 4/2/2024 in #help
friendship query that returns the other user object
for anyone coming across this in the future, this is the query that i ended up using
8 replies
DTDrizzle Team
Created by ! AlexNotTheLion on 4/2/2024 in #help
friendship query that returns the other user object
Not particularly what I was looking for, but thank you for your Insightful response
8 replies
DTDrizzle Team
Created by ! AlexNotTheLion on 2/19/2024 in #help
(Solved) Filter where json array contains
Agreed!
6 replies
DTDrizzle Team
Created by ! AlexNotTheLion on 2/19/2024 in #help
(Solved) Filter where json array contains
NAILED IT! thank you that was driving me nuts! i tried to use json contains but i wasnt stringifying the user id i passed to it !
6 replies
DTDrizzle Team
Created by ! AlexNotTheLion on 11/7/2023 in #help
[Solved] cannot find package 'mysql2'
nevermind, solved it by installing mysql2, apparently this is a known bug
2 replies