jkb
jkb
Explore posts from servers
DTDrizzle Team
Created by jkb on 2/20/2025 in #help
Order by on Joined Tables
I am attempting to do an order by for a joined table
export const playerItem = pgTable(
"playerItem",
{
id: uuid()
.primaryKey()
.default(sql`gen_random_uuid()`),
playerId: uuid().references(() => player.id),
...defaultColumns,
},
(t) => [index("player_item_pk_index").on(t.id)],
)
export const player = pgTable(
"player",
{
id: uuid()
.primaryKey()
.default(sql`gen_random_uuid()`),
fullName: text().notNull(),
firstName: text().notNull(),
lastName: text().notNull(),

...defaultColumns,
},
(t) => [index("player_pk_index").on(t.id)],
)
export const playerItem = pgTable(
"playerItem",
{
id: uuid()
.primaryKey()
.default(sql`gen_random_uuid()`),
playerId: uuid().references(() => player.id),
...defaultColumns,
},
(t) => [index("player_item_pk_index").on(t.id)],
)
export const player = pgTable(
"player",
{
id: uuid()
.primaryKey()
.default(sql`gen_random_uuid()`),
fullName: text().notNull(),
firstName: text().notNull(),
lastName: text().notNull(),

...defaultColumns,
},
(t) => [index("player_pk_index").on(t.id)],
)
I want to query playerItem with an order by on player.lastName descending. I don't see any examples in the documentation on how to do this or if Drizzle allows it. This is a simplified example of the schema, denormalizing would make sense here, but I purposely excluded the rest of the columns/relations to make reading easier Any help would be appreciated!
28 replies
DTDrizzle Team
Created by jkb on 12/12/2024 in #help
Drizzle Kit Generate renames columns incorrectly
No description
37 replies
TtRPC
Created by jkb on 6/11/2024 in #❓-help
Header caching
Hello all, I am sending an authorizaton token
export const TRPCProvider: React.FC<{
children: React.ReactNode;
}> = ({ children }) => {
const auth = useAuthentication();
const [queryClient] = React.useState(() => new QueryClient());
const [trpcClient] = React.useState(() =>
api.createClient({
transformer,
links: [
httpBatchLink({
async headers() {
const token = auth.isAuthenticated
? await auth.getAccessToken()
: null;
return {
Authorization: token,
};
},
url: `${getBaseUrl()}/api/trpc`,
}),
],
}),
);
export const TRPCProvider: React.FC<{
children: React.ReactNode;
}> = ({ children }) => {
const auth = useAuthentication();
const [queryClient] = React.useState(() => new QueryClient());
const [trpcClient] = React.useState(() =>
api.createClient({
transformer,
links: [
httpBatchLink({
async headers() {
const token = auth.isAuthenticated
? await auth.getAccessToken()
: null;
return {
Authorization: token,
};
},
url: `${getBaseUrl()}/api/trpc`,
}),
],
}),
);
The issue is the token being sent isn't updated when the authentication state of the application changes. For example, if I sign in, the authentication remains null, but if I refresh the app the token will update. Are there any ways to regenerate the header when the state changes. Thanks in advance for any help
3 replies