Skip to content

Conversation

@christophehurpeau
Copy link

Description

Summary of Changes

Allow $ne operator to accept null values.

null value is useful when we want to have a similar behavior as exists, but including null values even if the Value is not declared as nullable.

Notes for Reviewers

What is the motivation for this change?

Release Highlight

Release notes highlight

Double check the following

  • Lint is passing (npm run check:lint)
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

Allow $ne operator to accept null values. 

null value is useful when we want to have a similar behavior as exists, but including `null` values even if the Value is not declared as nullable.
@christophehurpeau christophehurpeau requested a review from a team as a code owner November 20, 2025 15:19
@tadjik1
Copy link
Member

tadjik1 commented Nov 25, 2025

Hi @christophehurpeau, thank you for the contribution! We are going to discuss this change internally as there are some usability and necessity questions arose. Can you maybe share the exact use-case or small snippet to demonstrate usage scenario, this would be extremely helpful.

@tadjik1 tadjik1 added External Submission PR submitted from outside the team tracked-in-jira Ticket filed in MongoDB's Jira system labels Nov 25, 2025
@christophehurpeau
Copy link
Author

@tadjik1

Of course.

Most of our models include an schema with non-nullable fields. Here a simple example:

interface EndUser {
  _id: Types.ObjectID;
  fullname: string;
  email?: string;
}

With an index on email.
When we want to query all enduser with existing emails:

const endUsers = await EndUserQueries.find({ email: { $ne: null } })

@dariakp dariakp changed the title Update $ne operator to include null type feat(NODE-7320): Update $ne operator to include null type Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Submission PR submitted from outside the team tracked-in-jira Ticket filed in MongoDB's Jira system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants