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

  • SEARCH
  • Home
  • 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 7491835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:10:58+00:00 2026-05-29T16:10:58+00:00

I have the following schema: { _id : 27, n : [{ d :

  • 0

I have the following schema:

{
  "_id" : 27,
  "n" : [{
      "d" : new Date("Sat, 24 Dec 2011 17:03:00 GMT +04:00"),
      "e" : ObjectId("4f0aef5346b3b88013000001"),
      "f" : [26, 10, 16],
      "k" : new Date("Mon, 09 Jan 2011 17:44:51 GMT +04:00"),
      "t" : "f",
      "u" : 10
    }, {
      "a" : ObjectId("4f0c208846b3b8140f000000"),
      "d" : new Date("Tue, 10 Jan 2012 15:27:21 GMT +04:00"),
      "p" : [ObjectId("4f0c209046b3b8340f000000"), ObjectId("4f0c209346b3b8340f000001"), ObjectId("4f0c209646b3b8340f000002"), ObjectId("4f0c209946b3b8340f000003")],
      "t" : "p",
      "u" : 10
    }]
}

and this query removes all of the sub elements if at least one satisfy it

db.newsFeed.update({ "_id" : 27, },{
$pull : {
 'n' : {
    'd' : {
        $lte : new Date(2012, 1, 1)
        }
    }
}
});

so the document becomes like this,
{
“_id” : 27,
“n” : []
}

what am I doing wrong, and more important what should I do to pull just some of the elements?

  • 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-05-29T16:10:59+00:00Added an answer on May 29, 2026 at 4:10 pm

    I think your query is fine, the problem is the date you’re using.

    Instead of:

    new Date(2012, 1, 1)
    

    Try:

    ISODate("2012-01-01")
    

    Try typing them in the shell by themselves and you’ll get back these results:

    > new Date(2012, 1, 1)
    ISODate("2012-02-01T07:00:00Z")
    
    > ISODate("2012-01-01")
    ISODate("2012-01-01T00:00:00Z")
    

    At least, that’s what I see in my shell. Using the “new” returns a date that matches on both elements of your array, so they’re both removed. Using ISODate directly creates the date object you’re looking for and only matches on the first result.

    The Date constructor takes a zero based month, so you want this if you want to use new:

    new Date(2012, 0, 1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following pseudo-SQL schema: table flight id int primary key date timestamp
Suppose I have the following schema: _id : 1, n : [{ a :
I have a collection with a following schema: { _id : 28, n :
I have the following DB Schema :- Data is ... Location Table 1. New
I have the following schema, which I use to ensure that a person's PhoneNumber
In a table I have the following schema table1: playerID int primary key, nationalities
I have the following table schema; CREATE TABLE `db1`.`sms_queue` ( `Id` INTEGER UNSIGNED NOT
I have a database where I store objects. I have the following (simplified) schema
Say you have the following in a schema: <xsd:complexType name=shape/> <xsd:complexType name=circle> <xsd:complexContent> <xsd:extension
Trying to map the following schema using the Entity Framework. A Customer can have

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.