Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7974319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:20:15+00:00 2026-06-04T08:20:15+00:00

I have an Email document which has a sent_at date field: { ‘sent_at’: Date(

  • 0

I have an Email document which has a sent_at date field:

{
  'sent_at': Date( 1336776254000 )
}

If this Email has not been sent, the sent_at field is either null, or non-existant.

I need to get the count of all sent/unsent Emails. I’m stuck at trying to figure out the right way to query for this information. I think this is the right way to get the sent count:

db.emails.count({sent_at: {$ne: null}})

But how should I get the count of the ones that aren’t sent?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:20:16+00:00Added an answer on June 4, 2026 at 8:20 am

    If the sent_at field is not there when its not set then:

    db.emails.count({sent_at: {$exists: false}})
    

    If it’s there and null, or not there at all:

    db.emails.count({sent_at: null})
    

    If it’s there and null:

    db.emails.count({sent_at: { $type: 10 }})
    

    The Query for Null or Missing Fields section of the MongoDB manual describes how to query for null and missing values.

    Equality Filter

    The { item : null } query matches documents that either contain the item field whose value is null or that do not contain the item field.

    db.inventory.find( { item: null } )
    

    Existence Check

    The following example queries for documents that do not contain a field.

    The { item : { $exists: false } } query matches documents that do not contain the item field:

    db.inventory.find( { item : { $exists: false } } )
    

    Type Check

    The { item : { $type: 10 } } query matches only documents that contain the item field whose value is null; i.e. the value of the item field is of BSON Type Null (type number 10) :

    db.inventory.find( { item : { $type: 10 } } )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this email sending code that does not show a chooser (good). How
We have a web application which has been developed over the past 7 months.
We have an email confirmation page for registration which can be hit with a
I have an email from a developer in which he says: As you may
I have 50 newsletters which all have different email accouts, hex colour codes and
In the page I'm developing I have a Email field and ConfirmEmail field. And
I have Ajax file in which code has written to accept values form user
I have a sql file which has a lot of insert statements (over 3000+).
I have my custom attr.xml document in which I specified declare-styleable : <?xml version=1.0
I have a DataTable which I get by an upload of CSV document from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.