这是收集会话
{
"_id": "R65i3SmvucW9imK2cxA6wdFb.GXoSHjly7obzFNslklNCBvE0UrW/qOiNmiBtPN24/1c",
"session": {
"channel": "all",
"username": "xuka"
},
"expires": NumberLong("1307692520000")
} {
"_id": "zJYZj2jwxa5zN0uZcCZC26zp.Tpp8fVkqwKLZEpRWgq7/3DDTcDw9VSlskBum28gox+0",
"session": {
"channel": "3",
"username": "hellos"
},
"expires": NumberLong("1307692826000")
}
Run Code Online (Sandbox Code Playgroud)
我需要找到通道不等于3的记录,下面是我尝试过的
var k =3;
db.collection('sessions', function(err, collection){
collection.find({channel:{'$ne':k}},function(err, cursor) {
});
});
Run Code Online (Sandbox Code Playgroud)
问题:结果给了我所有记录,其中channel = 3.这是错误的.