© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
20 replies
Scai

Query only one item from Many-To-Many

I would like only to take one stat not all the arrays. Is there a method to replace limit with something which returns only one item.
const res = await ctx.db.query.servers.findMany({
  with: {
    game: true,
    stat: {
      limit: 1,
      orderBy: (table, { desc }) => [desc(table.statId)],
      with: {
        stat: true,
      },
    },
  },
});
const res = await ctx.db.query.servers.findMany({
  with: {
    game: true,
    stat: {
      limit: 1,
      orderBy: (table, { desc }) => [desc(table.statId)],
      with: {
        stat: true,
      },
    },
  },
});
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

one to many query
Drizzle TeamDTDrizzle Team / help
3y ago
How to query from a many to many relationship?
Drizzle TeamDTDrizzle Team / help
3y ago
one-to-many
Drizzle TeamDTDrizzle Team / help
3y ago
Many to Many Query With
Drizzle TeamDTDrizzle Team / help
17mo ago