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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:10:44+00:00 2026-06-05T19:10:44+00:00

I’ve found some similar questions on StackOverflow, but nothing that addresses what I’m looking

  • 0

I’ve found some similar questions on StackOverflow, but nothing that addresses what I’m looking for, so any help would be appreciated.

My models:

class BlogPost(EmbeddedDocument):
  title = StringField(required=True)
  blog_url = StringField(required=True, unique=True)
  content = StringField()
  turned_into_bitly_link = BooleanField(default=False)

class Person(Document):
  name = StringField
  blog_posts = ListField(EmbeddedDocumentField(BlogPost), default=list)

For each blogpost.blog_url, I query the Bitly API to see if the url has been shortened. What I need to be able to do is match up the data I get back from Bitly with the appropriate blogpost in my database. The objects I get back from Bitly contain a url field that I need to use to match up and update the appropriate blogpost in my database. Should also say that I send a batch of blog_urls to Bitly at a time, one-by one is not an option.

Given a set of blog_posts and Bitly objects all stemming from a given individual:
person = Person.objects.get(name__exact=’BobSmith’)

How can I select the specific blog_post embedded in my Person object by the unique URL field?

As a stopgap, I suppose I could iterate over the blog_posts in my person object, and if the blog_post.url matches the URL in my Bitly object, I can then update the turned_into_bitly_link field, but I’m not sure this is the most efficient way of going about this.

Hope this makes sense. I’m happy to clarify, and thanks in advance for any advice.

Ben

  • 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-05T19:10:45+00:00Added an answer on June 5, 2026 at 7:10 pm

    You can use the positional operator to update the matched embedded document.

    Heres an example from the tests (https://github.com/MongoEngine/mongoengine/blob/master/tests/test_queryset.py#L313)

    def test_update_using_positional_operator(self):
        """Ensure that the list fields can be updated using the positional
        operator."""
    
        class Comment(EmbeddedDocument):
            by = StringField()
            votes = IntField()
    
        class BlogPost(Document):
            title = StringField()
            comments = ListField(EmbeddedDocumentField(Comment))
    
        BlogPost.drop_collection()
    
        c1 = Comment(by="joe", votes=3)
        c2 = Comment(by="jane", votes=7)
    
        BlogPost(title="ABC", comments=[c1, c2]).save()
    
        BlogPost.objects(comments__by="jane").update(inc__comments__S__votes=1)
    
        post = BlogPost.objects.first()
        self.assertEquals(post.comments[1].by, 'jane')
        self.assertEquals(post.comments[1].votes, 8)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.