is not assignable to type 'DrizzleD1Database'

11lluz10n5/21/2023
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
ASAndrii Sherman5/21/2023
Will try to check and fix it asap
11lluz10n5/21/2023
no rush, thanks for the help 🤟
MMaston5/21/2023
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,
  });
};
MMaston5/21/2023
works for me, i cloned your pr
MMaston5/21/2023
looks like a nice project you got also :SeemsGood:
11lluz10n5/21/2023
ohhhh I'm dumb 🫣🫣🫣

sorry for wasting your time with this 😅

thank you! drizzle has been amazing to work with. using on several projects