我一直在尝试用python和http://php.net/manual/en/function.fam-monitor-file.php查询一些mongo实例变量 我需要从所有Collection中的每个 RegistroPozo 中获取所有 Variable 。
示例代码:
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))