title: Parse query Javascript - "contains" on relational data
body: <p>Consider I have an object A having pointer to object B.
  Object B has a property "title" in it.
  I want to query on object A with a string which is contained in title of object B.
  Something like</p>
  
  <pre><code>var query1 = new Parse.Query("objectA");
  query1.include("objectB");
  query1.contains("objectB.title", anyQuery);
  query.find({
            success: function(obj){
       },
       error: function(obj, error) {    
       }
  });
  </code></pre>
  
  <p>"anyQuery" here can be any string entered by a user in search field. Consider a user inputs "Mary" as query I should get all objectA related to objectB having title containing "Mary" in it. For example "Maryland".
  Basically in simple words I want to execute a like query on related data in parse.</p>
  
  <h2>Edit</h2>
  
  <p>Thank you for the reply. I read the documentation at <a href="https://parse.com/docs/js_guide#queries-relational" rel="nofollow">https://parse.com/docs/js_guide#queries-relational</a>. I would like to extend my question. I want to use the query formed by matchesQuery in an or condition what I have done in my code is below but I get no results:</p>
  
  <pre><code>if(filterQuery) {
              var Organization = Parse.Object.extend("Organization");
  
              //LIKE QUERIES
              var nameLikeQuery = new Parse.Query(Parse.User);
              nameLikeQuery.contains("nameLc", filterQuery);  
  
              var phoneLikeQuery = new Parse.Query(Parse.User);
              phoneLikeQuery.contains("phone", filterQuery);      
  
              var emailLikeQuery = new Parse.Query(Parse.User);
              emailLikeQuery.contains("username", filterQuery);
  
              var organizationMatchQuery = new Parse.Query(Organization);         
              organizationMatchQuery.contains("titleLc", filterQuery);    
  
              var userOrganizationQuery = new Parse.Query(Parse.User);
              userOrganizationQuery.matchesQuery("organization", organizationMatchQuery);
  
              var userQuery1 = new Parse.Query.or(nameLikeQuery, phoneLikeQuery);
              var userQuery2 = new Parse.Query.or(emailLikeQuery, userQuery1);
  
              userQuery = new Parse.Query.or(userQuery2, userOrganizationQuery);
          } else {
              userQuery = new Parse.Query(Parse.User);
          }       
          if(type != "ALL") {
              userQuery.equalTo("userType", type);
          }
          userQuery.include("organization");
          userQuery.descending("createdAt");
          userQuery.find();
  </code></pre>