Need help inferring types of nested model

I'm new to drizzle, so obvious skill issue here, but how can I infer types from models with specific relations selected?

I know of InferSelectModel but I don't see a way to include relations.

Ideally I'd want to infer the type i get from something like this:

  async userById(id: string) {
    const user = await this.db.query.users.findFirst({
      where: eq(users.id, id),
      with: {
        teamMemberships: {
          columns: {
            role: true,
            createdAt: true,
          },
          with: {
            team: true,
          },
        },
      },
    });
    return user;
  }
Was this page helpful?