Created
August 22, 2012 11:16
-
-
Save jorgebastida/3424560 to your computer and use it in GitHub Desktop.
Revisions
-
jorgebastida created this gist
Aug 22, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ class Comment(db.EmbeddedDocument): ... visibility = db.IntField(default=0) mentions = db.ListField(db.GenericReferenceField()) class Message(db.Document): ... comments = db.ListField(db.EmbeddedDocumentField(Comment)) # I want the list of Messages that have comments that ment a particular user and they are visible (the comments): user = User.objects.get( ... ) Message.objects(__raw__={'comments': {'$elemMatch': {'visibility': 0,'mentions': {'_cls': 'User', '_ref': user.to_dbref()}}}})