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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:43:20+00:00 2026-06-16T05:43:20+00:00

I have a document in a Mongo collection which looks something like this: {

  • 0

I have a document in a Mongo collection which looks something like this:

{
  _id: [uuid]
  prop: 
    some: "text",
    subprop: ['foo', 'bar']
}

I’d like to avoid having to pull the whole record out, modify it and push it back if that’s possible. What update can I run to have 'bar' removed from doc.prop.subprop, not knowing the index it’s stored at?

Thanks 🙂

  • 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-16T05:43:21+00:00Added an answer on June 16, 2026 at 5:43 am

    You should be able to do this using the $pull operator, which can pull a specific value from a field. You can use dot notation to get the subprop field:

    db.foo.update( { _id : [uuid] }, { $pull : { "prop.subprop" : "bar" } } );
    

    If you want to run the update for multiple documents in the collection, you’ll need to set multi : true in your query with the following syntax:

    db.foo.update( { _id : [uuid] }, { $pull : { "prop.subprop" : "bar" } }, { multi : true } ); 
    

    This means that the update query will run on all documents that match { _id : [uuid] } in your collection.

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

Sidebar

Related Questions

I have a mongo collection which has documents with two fields fieldA and fieldB,
I have many collections of documents in a mongo database that look like this:
I have mongo documents in this format. {_id : 1,Summary : {...},Examples : [{_id
i have a document like this: English English English English 中文中文中文中文中文 English English English
If I have a Company collection which contains embedded Divisions: { _id: 1 _t:
i have this document in my collection foo provincia: { cod_provincia:5, nom_provincia:'Cordoba' }, localidad:
I have a mongo collection with documents. There is one field in every document
I have a Mongo collection called documents which has the following structure: { name:
I have a Mongo collection where each document has a set of unique embedded
*Mongo Newbie here I have a document containing several hundred numeric fields which I

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.