0
私はMongoDBを使い慣れていません。作成したすべての「投稿」をORしたいと思います。クエリmongoDB find()
router.get('/getPublicProfilePosts/:username',(req,res)=>{
if(!req.params.username){
res.json({success:false,message:"No username provided"});
}
else{
User.findOne({username:req.params.username},(err,user)=>{
if(err){
res.json({success:false,message:'Something went wrong '+err});
}
else{
if (!user) {
res.json({success:false,message:'User not found'});
}
else{
Post.find({createdBy:user.username, to:user.username},(err,posts)=>{ //this one
if(err){
res.json({success:false,message:'Something went wrong '+err});
}
else{
if (!posts) {
res.json({success:false,message:'Posts not found !'});
}
else{
res.json({success:true,posts:posts});
}
}
})
}
}
});
}
});
Post.find({CREATEDBY:にuser.username:user.usernameは}私は文がCREATEDBYとの両方を尊重しなければならない推測空の配列を返し