获取帖子的用户时遇到问题
用户架构及其所有相关的信息。
const answersSchema = new mongoose.Schema({
description: String,
code: String,
postDate: String
});
const questionsSchema=new mongoose.Schema({
title: String,
description: String,
code: String,
postDate: String,
answers: [answersSchema]
});
const blogpostsSchema=new mongoose.Schema({
title:String,
content:String,
postDate: String
});
const clientSchema= new mongoose.Schema({
email: String,
password: String,
googleId: String,
thumbnail: String,
blogPosts: [blogpostsSchema],
questions: [questionsSchema]
});
const Client = mongoose.model("Client",clientSchema);
const BlogPost= mongoose.model("BlogPost",blogpostsSchema);
const Answer = mongoose.model("Answer", answersSchema);
const Question =mongoose.model("Question",questionsSchema);
这是我的查询
Client.find({"blogPosts": {$exists: true}},function(err,foundUser){
if (foundUser){
console.log(foundUser)
res.render("blog",{userWithPosts: foundUser, clientStatus: clientStatus, logButton: logButton})
} else {
if(err){
console.log(err);
}
}
})
通过此查询,出现了问题。
我想要拥有博客帖子的客户
如何检查CLIENT是否在blogPosts中有帖子