人!
我正在尝试使用MongoDB(版本3.2)和MongoEngine并希望进行复杂的查询,但我完全不知道如何制作它。如果它甚至可能。
有4个文件:
class File(EmbeddedDocument):
path = StringField()
class Episode(EmbeddedDocument):
num = IntField()
alias = StringField()
files = EmbeddedDocumentListField('File')
class Season(Document):
num = IntField()
alias = StringField()
episodes = EmbeddedDocumentListField('Episode', db_field='items')
class Series(Document):
title = StringField()
alias = StringField()
description = StringField()
seasons = ListField(ReferenceField('Season'), db_field='items')
我需要进行返回以下表单响应的查询:
[{
"path": "/series/<series alias>",
"title": "<series title>",
"description": "<series description>",
"seasons": [{
"path": "/series/<aseries alias>/<season alias>",
"title": "Season <season num>",
"episodes": [{
"path": "/series/<series alias>/<season alias>/<episode alias>",
"title": "Episode <episode num>",
"files": [{
"path": "<path>"
}]
}]
}]
}]
是否可以仅使用一个查询接收响应?