© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago
Mixed Nuts

Select<Type> Help

Random, but how can I get this to be type safe?

type Reports = {
    character: typeof characters.$inferSelect & {
        faction: typeof factions.$inferSelect,
        guild: typeof guilds.$inferSelect & {
            faction: typeof factions.$inferSelect
        }
    },
    log: typeof logs.$inferSelect
}
const characterFaction = alias(factions, 'characterFaction')
const guildFaction = alias(factions, 'guildFaction')

const preparedReports = db.select({
    character: {
        ...characters,
        faction: characterFaction,
        guild: {
            ...guilds,
            faction: guildFaction
        }
    },
    log: logs

}) 
//...
type Reports = {
    character: typeof characters.$inferSelect & {
        faction: typeof factions.$inferSelect,
        guild: typeof guilds.$inferSelect & {
            faction: typeof factions.$inferSelect
        }
    },
    log: typeof logs.$inferSelect
}
const characterFaction = alias(factions, 'characterFaction')
const guildFaction = alias(factions, 'guildFaction')

const preparedReports = db.select({
    character: {
        ...characters,
        faction: characterFaction,
        guild: {
            ...guilds,
            faction: guildFaction
        }
    },
    log: logs

}) 
//...

I get the object exactly how I want it but just not the type safety where it knows the Reports type is the actual selected type
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Type Helper to select fields
Drizzle TeamDTDrizzle Team / help
3y ago
nested select type issue
Drizzle TeamDTDrizzle Team / help
14mo ago
MySQL select().from() type
Drizzle TeamDTDrizzle Team / help
2y ago
Get type from select object ?
Drizzle TeamDTDrizzle Team / help
2y ago