0
我一直想查詢一些蒙戈實例變量,Python和MongoEngine 我需要從每一個RegistroPozo得到所有變量在所有的收藏。Quering嵌套文件查詢與Mongoengine
示例代碼:
from mongoengine import *
class Variable(EmbeddedDocument):
mnem=StringField(required=True, max_length=200)
description=StringField(max_length=500)
unit=StringField(max_length=200,default='ppm')
alias=StringField(max_length=200) #,default=mnem
type=StringField(max_length=200,default='DEPENDANT')
class RegistroPozo(EmbeddedDocument):
fecha = DateTimeField()
filepath = StringField()
start = FloatField()
step = FloatField()
stop = FloatField()
variables = EmbeddedDocumentListField(Variable)
registros = ListField(DictField())
version_information_block = StringField(max_length=500)
well_information_block = StringField(max_length=500)
curve_information_block = StringField(max_length=500)
parameter_information_block = StringField(max_length=500)
other_block = StringField(max_length=500)
class Pozo(DynamicDocument):
uwi_pozo = StringField(required=True, max_length=200, primary_key=True)
nom_pozo = StringField(required=True, max_length=200)
prof_total = FloatField(required=True)
elev_terr = FloatField(required=True)
long_pozo = FloatField(required=True)
lat_pozo = FloatField(required=True)
coord_x_po = FloatField(required=True)
coord_y_po = FloatField(required=True)
registros_pozo=EmbeddedDocumentListField(RegistroPozo)
當我嘗試查詢我做了很多圈,但我相信有一個更好的辦法做到這一點。 喜歡的東西:
variables_in_all_the_doc = Pozo.objects(Q(AdvanceQuery))