title: mongoose fetch posts by user and by his followings
body: <p>How to fetch posts by user and all his followings posts (Mongodb, Mongoose, Nodejs)</p>
  
  <p>User Schema</p>
  
  <pre><code>const userSchema = new mongoose.Schema({
      firstName: { type: String, required: true, trim: true },
      lastName: { type: String, required: true, trim: true },
  });
  userSchema.set('timestamps', true);
  
  export default mongoose.model('user', userSchema);
  </code></pre>
  
  <p>Followers Schema</p>
  
  <pre><code>const followSchema = new mongoose.Schema({
      follower: { type: mongoose.Schema.Types.ObjectId, ref: 'user' },
      following: { type: mongoose.Schema.Types.ObjectId, ref: 'user' },
      status: { type: Boolean, default: true }
  });
  followSchema.set('timestamps', true);
  
  export default mongoose.model('follow', followSchema);
  </code></pre>
  
  <p>Posts Schema</p>
  
  <pre><code>const postSchema = new mongoose.Schema({
      userId: { type: mongoose.Schema.Types.ObjectId, ref: 'user' },
      contents: { type: String, trim: true },
      photo: { type: String }
  });
  postSchema.set('timestamps', true);
  
  export default mongoose.model('post', postSchema);
  </code></pre>
  
  <p>Thank you in advance! :)</p>