我这样做:
res.jsonp({
userId: user._id,
spotUserId: spot.user._id,
condition: (user._id === spot.user._id)
});
结果如下:
{
"userId": "551192836bff030fb657777c",
"spotUserId": "551192836bff030fb657777c",
"condition": false
}
我不明白为什么病情是假的......救命我!
答案 0 :(得分:0)
在ExpressJS中用于比较Mongoose ObjectsID, .id 不是 _id 。
示例:
res.jsonp({
userId: user._id,
spotUserId: spot.user._id,
condition: (user.id === spot.user.id)
});
结果:
{
"userId": "551192836bff030fb657777c",
"spotUserId": "551192836bff030fb657777c",
"condition": true
}