Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Teamβ€’2y agoβ€’
146 replies
dhakan

SQLite 'WHERE table.relationship (one to many) > 0'

Hi! I'm trying to figure out how to query for rows that have a relationship at least defined once.
  const allVideos = await db.query.videos.findMany({
    where: // Not all videos have timestamps (one-to-many). Exclude those somehow
    with: {
      timestamps: true
    },
  });

  // Below should not be done in memory.
  return allVideos.filter(
    (video) => video.timestamps.length > 0
  );
  const allVideos = await db.query.videos.findMany({
    where: // Not all videos have timestamps (one-to-many). Exclude those somehow
    with: {
      timestamps: true
    },
  });

  // Below should not be done in memory.
  return allVideos.filter(
    (video) => video.timestamps.length > 0
  );

Can't seem to find any examples of this in the docs. Any help would be greatly appreciated, thanks.
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

SQLite - one to many relationship, join only returning first match
Drizzle TeamDTDrizzle Team / help
3y ago
Many to many relationship between one type
Drizzle TeamDTDrizzle Team / help
3y ago
Many-to-Many where in far table
Drizzle TeamDTDrizzle Team / help
3y ago
update many to many relationship
Drizzle TeamDTDrizzle Team / help
11mo ago
Next page