Incorrect return type findFrist

Hi! I just upgraded to 26.0 and I'm refactoring queries to findFirst where needed. But the return type is not correctly inferred! The return type is just
const user: {
[x: string]: never;
} | undefined
const user: {
[x: string]: never;
} | undefined
see https://imgur.com/a/BlYG4Mj users schema:
export const users = mysqlTable(
'auth_user', {
id: serial('id').primaryKey().notNull(),
email: varchar('email', { length: 191 }).notNull(),
emailVerified: timestamp('emailVerified'),
verificationCode: varchar('verificationCode', { length: 255 }),
},
(user) => ({
emailIndex: uniqueIndex('users__email__idx').on(user.email),
verificationCodeIndex: uniqueIndex('users__verificationCode__idx').on(user.verificationCode),
}),
)
export const users = mysqlTable(
'auth_user', {
id: serial('id').primaryKey().notNull(),
email: varchar('email', { length: 191 }).notNull(),
emailVerified: timestamp('emailVerified'),
verificationCode: varchar('verificationCode', { length: 255 }),
},
(user) => ({
emailIndex: uniqueIndex('users__email__idx').on(user.email),
verificationCodeIndex: uniqueIndex('users__verificationCode__idx').on(user.verificationCode),
}),
)
I'm using mysql with the planetscale adapter
4 Replies
Andrii Sherman
Can you show drizzle db creation and imports for it?
Qube117
Qube117OP2y ago
This is my db.ts file
import { drizzle } from 'drizzle-orm/planetscale-serverless'
import { connect } from '@planetscale/database'
import { serverEnv } from '$lib/server/serverEnv'

// create the connection
export const connection = connect({
host: serverEnv.DATABASE_HOST,
username: serverEnv.DATABASE_USERNAME,
password: serverEnv.DATABASE_PASSWORD,
})

export const db = drizzle(connection)
import { drizzle } from 'drizzle-orm/planetscale-serverless'
import { connect } from '@planetscale/database'
import { serverEnv } from '$lib/server/serverEnv'

// create the connection
export const connection = connect({
host: serverEnv.DATABASE_HOST,
username: serverEnv.DATABASE_USERNAME,
password: serverEnv.DATABASE_PASSWORD,
})

export const db = drizzle(connection)
and I just import it justing import { db } from '$lib/db/db' (i'm using sveltekit $ is just an allias)
Andrii Sherman
You need to pass your tables and relations to 2nd param of drizzle() You can check: https://orm.drizzle.team/docs/rqb
Qube117
Qube117OP2y ago
Whoops totally my fault! I was too hyped, and completely missed that part
Want results from more Discord servers?
Add your server