Y
Y
Yuri Matveenko2018-05-20 02:24:04
MongoDB
Yuri Matveenko, 2018-05-20 02:24:04

How to get all users except?

It turned out to get all users except '[email protected]':

models.user.find({ email: { $ne: ['[email protected]'] } } , (err, result) => {
        console.log(result);
        socket.emit('update user list', result);
    }, { email: 1 });

But how to get all users except for two or three users?
When I insert more than one email into $ne, all users are displayed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Matveenko, 2018-05-20
@letsrock_inita

It turned out like this...

models.user.find({ email: { $not: { $in: ['...', '...'] } } } , (err, result) => {
        console.log(result);
        socket.emit('update user list', result);
    }, { email: 1 });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question