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 6662395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:23:06+00:00 2026-05-26T02:23:06+00:00

I have nodes like this: [_id] => MongoId Object ( [$id] => 4e90cb3cd68417740c000017 )

  • 0

I have nodes like this:

[_id] => MongoId Object (
    [$id] => 4e90cb3cd68417740c000017
)
[label] => mystery
[owner] => me
[parents] => Array (
    [0] => Array (
        [id] => MongoId Object (
            [$id] => 4e8c6bb6d68417340e0004ca
        )
        [owner] => userid
        [timestamp] => 1318112522
    )
)
[timestamp] => 1318112060
[translabel] => mystery
[type] => 0

What I am trying to do is to remove parents with id : 4e8c6bb6d68417340e0004ca , wherever they are.

For example this should have been working (latest Mongo):

db.nodes.update({},{$pull : {"parents": { "id" : ObjectId("4e8c6bb6d68417340e0004ca") }}});

or equaly in PHP (latest driver etc):

$mongodb->nodes->update(array(),array('$pull'=> array('parents'=>array('id'=> new MongoId("4e8c6bb6d68417340e0004ca")))));

both don’t do anything!


on the other hand:

db.nodes.update({"_id": ObjectId("4e90cb3cd68417740c000017")},{$pull : {"parents": { "id" : ObjectId("4e8c6bb6d68417340e0004ca") }}});

or equaly in PHP:

$mongodb->nodes->update(array('_id' => new MongoId("4e90cb3cd68417740c000017"),array('$pull'=> array('parents'=>array('id'=> new MongoId("4e8c6bb6d68417340e0004ca")))));

work perfectly well! Is this a bug? Is it a problem that I use “id” instead of “_id” with MongoID objects in my subdocuments? Thanks in advance for any help!

  • 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-26T02:23:06+00:00Added an answer on May 26, 2026 at 2:23 am

    Have you tried enable multi flag on update command

    db.collection.update( criteria, objNew, upsert, multi )
    

    multi – indicates if all documents matching criteria should be updated rather than just one. Can be useful with the $ operators below.

    and change your query to

    db.nodes.update({},{$pull : {"parents": { "id" : ObjectId("4e8c6bb6d68417340e0004ca") }}},false,true);
    

    or

    db.nodes.update({ "_id" : { $exists : true } },{$pull : {"parents": { "id" : ObjectId("4e8c6bb6d68417340e0004ca") }}},false,true);
    

    i haven’t tested the code myself, but am sure that any one of the above will work..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a treeview with nodes like this: Foo (1234), and want to allow
I have a data object that looks like this: { 'node-16': { 'tags': ['cuda'],
So I have something like this: var xmlStatement:String = xmlObject.node[3].@thisValue; What mystery function do
I have to do something like this insert into object (name, value, first_node) values
I have an xml document with multiple nodes that looks something like this: <Result>
I have a XML source with nodes like this (Somewhat anonymized): <XXX> <Code A=oa
I have an XML stylesheet with variable child nodes, something like this: <fooz> <foo>
I have something like this: <node TEXT= txt A /> <node TEXT= txt X
I have a invalid XML like this Warning: count() [function.count]: Node no longer exists
I have a xml document like this : <Node1 attrib1=abc> <node1_1> <node1_1_1 attrib2 =

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.