users with documents containing an age field, which query returns all users whose age is not 30?db.users.find({ age: { $ne: 30 } })The $ne operator selects documents where the value of the field is not equal to the specified value. Here, { age: { $ne: 30 } } finds all users whose age is anything but 30.
db.collection.find({ field: { $ne: null } }) return?The $ne: null condition matches documents where the field does not exist or its value is not null. It excludes documents where the field exists and is null.
Option C is invalid because the operator $ne must be inside an object as a key, not used directly as a key-value pair without braces.
status is not 'active'?Option A uses $ne directly, which is straightforward and efficient. Options A and C are more complex and may be less efficient. Option A adds an unnecessary $exists check.
db.products.find({ category: { $ne: 'electronics' } }). It returns documents where category is missing. Why does this happen?The $ne operator matches documents where the field value is not equal to the specified value or where the field does not exist at all. This is why documents missing the category field are included.