orderBy in nested findMany

The docs suggest that I can order a nested findMany (https://orm.drizzle.team/docs/rqb#order-by)
Like so:
await db.query.posts.findMany({
  orderBy: (posts, { asc }) => [asc(posts.id)],
  with: {
    comments: {
      orderBy: (comments, { desc }) => [desc(comments.id)],
    },
  },
});


But when I attempt to do something similar:
  const projects = await db().query.projects.findMany({
    with: {
      projectInfo: {
        orderBy: (projectInfo, { asc }) => [asc(projectInfo.name)]
      },
    },
  });

I get the type error : Object literal may only specify known properties, and orderBy does not exist in type

How can I orderBy an attribute in a nested query? The projectInfo is a one-to-one relation with projects. I want to order projects by projectInfo.name? Is there a way I can do this using the query syntax?
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Was this page helpful?