Skip to main content

What does $ne do?

$ne (not equal) is an operator that selects documents where a field's value doesn't equal the given one.

Example:

js
db.users.find({ age: { $ne: 25 } })

This query returns every user whose age doesn't equal 25.

The gist of it: $ne is the opposite of $eq. It excludes documents with a specific value.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.