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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:47:46+00:00 2026-06-03T16:47:46+00:00

I have a document and a embedded document using MongoEngine class Sub(EmbeddedDocument): Id =

  • 0

I have a document and a embedded document using MongoEngine

class Sub(EmbeddedDocument):
    Id = StringField()
    User = StringField()
    Value = StringField()


class Main(Document):
    Value = StringField
    Values = ListField(EmbeddedDocumentField(Sub))

When I add new embedded documents into Main’s ‘Values’ field, I generate a unique id to the list not to the collection, There can be multiple Sub in Main’s ‘values’ each from different User’s, I am trying to get MongoEngine to atomically remove a “Sub” value from the List, based on the ID and the User.

I have tried to run a select for the Main, then a update_one for the Sub itself

Main.objects(id=main_id).update_one(pull__values__id=sub_id) 

But all this seems to return is the index inside of the array. I know I could simply pull the Main, and go through the Values find the element and remove it, but I am trying to keep this atomic and with less chances of something being added to sub during the pull, iterate, update process.

  • 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-03T16:47:48+00:00Added an answer on June 3, 2026 at 4:47 pm

    Just use EmbeddedDocument class to pass sub_id

    Main.objects(id=main_id).update_one(pull__values__id = Sub(Id=sub_id).Id )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have products as an embedded document inside the category class as shown below:
I have a Word document with two embedded Excel files (added using Insert ->
Using Mongoid, let's say I have the following classes: class Map include Mongoid::Document embeds_many
I have embedded the fullcalendar jquery control by using this code: $(document).ready(function() { var
I have a Recipe model, which has Ingredients embedded in it, using Mongoid. class
Currently I have an address column that is an embedded document in my users
I have a document-based Core Data app. My main Core Data entity has several
I have a document with an embedded document in it. I have 2 forms,
Problem: I have a 'Group' collection. Each group has an embedded document of 'Members'.
I run a sinatra application with mongomapper. I have models called Movie(Document) and Cover(EmbeddedDocument).

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.