django-nonrel / djangotoolbox

Django tools for building nonrel backends
BSD 3-Clause "New" or "Revised" License
201 stars 124 forks source link

dot notation support or append a new document inside embedded model inside a document #39

Closed hackerunet closed 10 years ago

hackerunet commented 11 years ago

sorry but I'm not using google app engine, just using django-nonrel with djangotoolbox and mongoengine, and I just saw the site you sent and it has no information about what I'm looking for, can you give me a hand on this? I have this collection in mongo:

{ "_id" : ObjectId("517f00dbe138234abbf790bb"), "campaigns" : [ { "payout" : 0.7, "landing_page" : [ ], "rotate_urls" : null, "_module" : "setup.models", "_model" : "Campaigns", "cloaking" : true, "campaign_name" : "DOS", "rotate_urls_status" : false, "affiliate_url" : "http://www.DOS.com/[[subid]]" } ], "category_name" : "category2" }

how can I append a embed document into landing_page using django-nonrel, mongoengine without djangodbindexer support?? I have tried this but I always receive errors: landingpage = LandingPages(nickname=lpnickname,url=lpurl) b = Categories.objects.get(id=affnetworkid,campaigns__campaign_name=campaignname) b.landing_page.append(landingpage) b.save()

The mongoengine documentation says that doble underscore is supported, but, the fact is that django-nonrel or the mongoengine is trying to execute a join which is not what I'm looking for, how can I use dot notation on this?? how can I just add more documents to the landing_page list type inside campaigns??? thanks note: I have 8 days trying to achieve this.

aburgel commented 11 years ago

i don't know the answer to your question. but you might have more luck on the forum or reading the mongodb-engine issues list, for example here:

django-nonrel/mongodb-engine/issues/115

aburgel commented 10 years ago

Hi, sorry for the very delayed response to this. You can solve this problem by using an A() expression or by using raw queries. If you look in django_mongodb_engine/query.py, you'll see how A() expressions work. They are marked as deprecated but we're looking to replace them with something similar, so don't worry about the deprecation.

You can also look at django-nonrel/mongodb-engine#178, which is a pull request that is adding some of these features in a more natural django way.