title: Mongoose/mongoDB query joins.. but I come from a sql background
body: <p>I coming from a sql background so writing queries in sql where I join tables is quite simple but I guess I am missing that in mongoose/mongodb</p>
  
  <p>Basically I know the Subscriber_ID (which maps to a document in the User Collection)</p>
  
  <p>I want to pull the project group, with all the projects that the user belongs to so if I was to write this in pseduo sql it would be like</p>
  
  <pre><code>Select 
    ProjectGroup.title, 
    Project.Title 
  FROM 
    ProjectGroup, 
    Project, 
    User 
  WHERE 
    User.id = req.body.subscriber_id 
    AND Project.subscriber_id = User.id 
    AND  ProjectGroup.project_id = Project.id
  </code></pre>
  
  <p>There must be a way to do similiar joins in mongoose/mongodb because the type is mapping to a schema right?</p>
  
  <p>My Schemas.....</p>
  
  <p>Project Group Schema</p>
  
  <pre><code>var ProjectGroupSchema = new Schema({
      title             : String
    , projects          : [ { type: Schema.Types.ObjectId, ref: 'Project' } ]
  });
  </code></pre>
  
  <p>Project Schema</p>
  
  <pre><code>var ProjectSchema = new Schema({
      title         : {type : String, default : '', required : true}
    , subscribers   : [{ type: Schema.Types.ObjectId, ref: 'User' }]
  });
  </code></pre>
  
  <p>User Schema</p>
  
  <pre><code>var UserSchema = new Schema({
      first_name    : {type: String, required: true}
    , last_name     : {type: String, required: true}
  });
  </code></pre>
  
  <p>Thank you!</p>