NodeJS/Mongoose - How to reference individual models after concatenation? NodeJS/Mongoose - How to reference individual models after concatenation? mongoose mongoose

NodeJS/Mongoose - How to reference individual models after concatenation?


With mongoose documents it can be distinctly verified which Model they belong to using instance of :

  const blogs = await Blog.find({});  const events = await Event.find({});  const blogsAndEvents = blogs.concat(events);  blogsAndEvents.forEach(function (blogOrEvent) {    if (blogOrEvent instanceof Blog) {      title = "BLOG";    } else if (blogOrEvent instanceof Event) {      title = "EVENT";    }  });