Adonis wo hat

// Testing code
var result = User.query()
    .with("posts", builder => {
      // Filter on the posts array
      builder.where("cond1", "2");
      builder.where("cond2", "3");
    })
    .whereHas("posts", builder => {
      // Filter user
      builder.where("cond1", "1");
      builder.where("cond2", "3");
    })
    .fetch();
GutoTrosla