I am using MongoDb for a blogging website and I have the following object
from mongoengine import connect,Document,StringField,ListField
class Comment(Document):
content = "hi"
class BlogPost(Document):
comments = ListField(StringField())
As shown above, I have a BlogPost object with a comments attribute. I would like this comments attribute to be a list of all the comments associated with that blog post. The list would contain all the Comment objects associated with that BlogPost.
I am just wondering, how can 'put' the comments in the list? Should I put all their id numbers in the list, then initiate the Comment object later?
Thank you in advance.