Nodejs Follow System Not Working Properly

匆匆过客 提交于 2021-02-08 08:42:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!