can we filter by a prop on a relation during a query?

eg. watch has watch brands + watch families as relations

if i wanted to search across watch name, watch brand name + watch family name should that be possible?

current query just using watch name

const items = await ctx.db.query.watch.findMany({
            ...withCursorPagination({
              limit: 10,
              cursors: [[schema.watchBrand.name, "desc", cursor]],
            }),
            where: and(
              like(schema.watch.name, `%${input.name}%`),
              notInArray(schema.watch.id, usersWatches),
            ),
            with: {
              watchBrand: true,
              watchFamily: true,
            },
          });
Was this page helpful?