Sunday 12 March 2017

mongoose query except array items

The problem is that I have an array which maybe like [1,2,3], and the content is video._id I don't want to get.

var used = [1, 2 , 3];
Video.findOne({'videoClass': watchRecord[i]}).ne('_id', used).sort('-viewTimes').exec(function (err, doc) {
            if (err){
                console.log(err);
                return;
            }
            temp.push(doc);

            }
        });

I find ne or {$ne:}, but it's not work. How to query data that except items in array I don't want?



via PaulHuang

No comments:

Post a Comment