is not assignable to type 'DrizzleD1Database'

Hello This last release was amazing. Making joins simple was the missing piece for me. However, I'm trying to upgrade https://race-stack.pages.dev to the new API (it previously used the joins). I'm getting the error from the screenshot. Not sure what's going on, created a PR with it. Here's the PR - https://github.com/jose-donato/race-stack/pull/2 schema - https://github.com/jose-donato/race-stack/blob/f5ce04cdae134302c94e2de671c7a272274dab36/app/lib/schema.ts db initialization - https://github.com/jose-donato/race-stack/blob/f5ce04cdae134302c94e2de671c7a272274dab36/app/lib/db.service.server.ts
GitHub
race-stack/schema.ts at f5ce04cdae134302c94e2de671c7a272274dab36 · ...
Remix run stack built for the edge (cloudflare pages and d1) - race-stack/schema.ts at f5ce04cdae134302c94e2de671c7a272274dab36 · jose-donato/race-stack
GitHub
race-stack/db.service.server.ts at f5ce04cdae134302c94e2de671c7a272...
Remix run stack built for the edge (cloudflare pages and d1) - race-stack/db.service.server.ts at f5ce04cdae134302c94e2de671c7a272274dab36 · jose-donato/race-stack
4 Replies
Andrii Sherman
Andrii Sherman•2y ago
Will try to check and fix it asap
1lluz10n
1lluz10nOP•2y ago
no rush, thanks for the help 🤟
Maston
Maston•2y ago
not a bug with drizzle, you explicitly type the return type of that function as DrizzleD1Database which is not assignable, try DrizzleD1Database<typeof schema>
export const getDbFromContext = (
context: Record<string, unknown>
): DrizzleD1Database<typeof schema> => {
if (!contextWithDb(context)) {
throw new Error("No database in context");
}

return drizzle(context.DB, {
schema,
});
};
export const getDbFromContext = (
context: Record<string, unknown>
): DrizzleD1Database<typeof schema> => {
if (!contextWithDb(context)) {
throw new Error("No database in context");
}

return drizzle(context.DB, {
schema,
});
};
works for me, i cloned your pr looks like a nice project you got also SeemsGood
1lluz10n
1lluz10nOP•2y ago
ohhhh I'm dumb 🫣🫣🫣 sorry for wasting your time with this 😅 thank you! drizzle has been amazing to work with. using on several projects
Want results from more Discord servers?
Add your server