0

I have an array named blogs inside the array exists these objects:

var blogs = new mongoose.Schema({
title: String,
image: String,
body: String,
author: {
  id: {
     type: mongoose.Schema.Types.ObjectId,
     ref: "User"
  },
  username: String
 },comments: [
  {
     type: mongoose.Schema.Types.ObjectId,
     ref: "Comment"
  }
 ],
 created: {type: Date, default: Date.now}
});

i want to make a forEach that only shows the blogs that have the same username example admin. My forEach code

blogs.forEach(function(blog){
// prints blogs
}

0 Answers0