python - What is the proper way to update a listfield of embedded documents in mongoengine? -
I am trying to define ways to check and update the list of embedded documents in the field field. I am trying, what is the proper way to do it is the code is below. Is this the right way to go about something like this? You can use EmbeddedDoclockLilffield instead of the list of embedded documents. This way you get access to something like Filters , create or updates :
class comment (Embedded document): created = datetimefild () text = stringfield () class post (document): comments = EmbeddedLilifffield (comment) ... def add_or_replace_comment (self, comment): existing = self.comments.filter (created = comment. Cents) if existing (no code test) html>
Comments
Post a Comment