melodyclue
melodyclue
Explore posts from servers
DTDrizzle Team
Created by melodyclue on 2/28/2024 in #help
Followers count
I want to put the number of followers and likes, can I use the Count() honestly?
7 replies
DTDrizzle Team
Created by melodyclue on 2/23/2024 in #help
json_arrayagg(json_array ...
db.query.team.findFirst({
where: eq(t.slug, params.slug),
with: {
members: true,
},
});
db.query.team.findFirst({
where: eq(t.slug, params.slug),
with: {
members: true,
},
});
this SQL is
{
sql: 'select `id`, `slug`, `name`, `subtitle`, `avatar_url`, `created_at`, `updated_at`, coalesce((select json_arrayagg(json_array(`id`, `team_id`, `user_id`, `role`, `created_at`, `updated_at`)) from `team_member` `team_members` where `team_members`.`team_id` = `team`.`id`), json_array()) as `members` from `team` where `team`.`slug` = ? limit ?',
params: [ 'melodyclue-team', 1 ]
}
{
sql: 'select `id`, `slug`, `name`, `subtitle`, `avatar_url`, `created_at`, `updated_at`, coalesce((select json_arrayagg(json_array(`id`, `team_id`, `user_id`, `role`, `created_at`, `updated_at`)) from `team_member` `team_members` where `team_members`.`team_id` = `team`.`id`), json_array()) as `members` from `team` where `team`.`slug` = ? limit ?',
params: [ 'melodyclue-team', 1 ]
}
but
const sq = db
.select({
members: sql`json_arrayagg(json_array(${teamMember.id},${teamMember.userId},${teamMember.role},${teamMember.createdAt},${teamMember.updatedAt}))`,
})
.from(teamMember)
.where(eq(teamMember.teamId, t.id));

const data = await db
.select({
id: t.id,
name: t.name,
subtitle: t.subtitle,
slug: t.slug,
avatarUrl: t.avatarUrl,
createdAt: t.createdAt,
updatedAt: t.updatedAt,
members: sql`coalesce(${sq}, json_array())`.as("members"),
})
.from(t)
.where(eq(t.slug, params.slug));
const sq = db
.select({
members: sql`json_arrayagg(json_array(${teamMember.id},${teamMember.userId},${teamMember.role},${teamMember.createdAt},${teamMember.updatedAt}))`,
})
.from(teamMember)
.where(eq(teamMember.teamId, t.id));

const data = await db
.select({
id: t.id,
name: t.name,
subtitle: t.subtitle,
slug: t.slug,
avatarUrl: t.avatarUrl,
createdAt: t.createdAt,
updatedAt: t.updatedAt,
members: sql`coalesce(${sq}, json_array())`.as("members"),
})
.from(t)
.where(eq(t.slug, params.slug));
this is not one I want. Is this drizzle-related issue?
2 replies
TtRPC
Created by melodyclue on 7/20/2023 in #❓-help
Sometimes invalidate not work...
No description
22 replies