Filter on included relations

Hello! Hope you're all doing well!
Is it possible to filter based on included relations?
return await this.db.query.myTable.findMany({
      with: {
        relations: true,
      },
      where: (doc, { and, eq, inArray }) => {
        const predicates: SQL[] = [];
        predicates.push(
          eq(schema.relationTable.type, "my-type"),
        );
        predicates.push(
          eq(schema.relationTable.value, value.toString()),
        );

        return predicates.length > 0 ? and(...predicates) : undefined;
      },
    });
Was this page helpful?