I have define the class statement:
from mongoengine import *
class TickDataDocument(Document):
"""
"""
instrument_id = StringField(max_length=10, unique=True, required=True)
tick_data = ReferenceField(TickDocument)
class TickDocument(Document):
"""
"""
price = DecimalField(precision=2, required=True)
volume = LongField(required=True)
turnover = DecimalField(precision=2, required=True)
update_time = DateTimeField(unique=True, required=True)
I want to query the update_time in some period of time.
TickDataDocument.objects(instrument_id="fa1100").filter(tick_data__ update_time__lt =datetime.datetime(2013,9,3))
but I got errors:
mongoengine.errors.InvalidQueryError: Cannot perform join in mongoDB: tick_data__update_time
How could I to five a solution to query the inner reference field in mongoengine.
As suggested in a comment, I do this in two steps (two queries):
tick_docs = list(TickDocument.object(update_time__lt)=datetime.datetime(2013,9,3))
TickDataDocument.objects(instrument_id="fa1100").filter(tick_data__in=tick_docs)
If there is any simpler solution, I'm interested as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With