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; }, });