First of all i have these mongoose schemas user schema
var UserSchema = new mongoose.Schema({
username: String,
email: String,
password: String,
types: [
{
type: String,
ref: "types"
}
],
follow: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "follow"
}
]
});
and the blog schema
var blogSchema = new mongoose.Schema({
title: String,
image: String,
body: String,
category: String,
author: {
id: {
type: mongoose.Schema.Types.ObjectId,
ref: "User"
},
username: String
}, likes: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "likes"
}
],
comments: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "Comment"
}
],
created: {type: Date, default: Date.now}
});
Now i have made it so user.follow and blog.author.id so that for some users those have the same id but the thing is that i want to be able to show in a ejs file all the blogs that have the same id. I have tried this
<% var specificBlogss =
currentUser.follow.valueOf()currentUser.follow.indexOf == blog.author.id) %>
<% specificBlogss.forEach(function(blog){ %>
//things about the blogs
<%} %>
via fanffis theologiths
No comments:
Post a Comment