问题
I have a follow system
app.get('/user/:id', function(req, res){
User.findById(req.user
).exec(function(err, user){
User.findById(req.params.id, function(err, kullanici){
User.findById(user, {follower:kullanici._id}, function(err, follow){
if(follow== ""+kullanici._id+""){
console.log("sdasdsad")
}else{
console.log("no")
}
...
kullanici= user in profile
user= current user
follow =the users who follows the kullanici
When current user is one of the takip then I will console log sdasdsad but else I will console.log no.
But it always returns as no in my console.
Why it is not working?
And also it is my user.js part:
follower:[{
type: ObjectId,
}]
When I do console.log(follow)
{ follower:
[ 5edfe8f3bfc9d677005d55ca,
5edfe92fbfc9d677005d55cc,
5ee2326cc7351c5bb0b75f1a ],
_id: 5eef29617e748990845fd7b1 }
When I do console.log(kullanici._id)
5edfe92fbfc9d677005d55cc,
来源:https://stackoverflow.com/questions/62626123/nodejs-follow-system-not-working-properly