I have a query like below
query = PhotoLocation.query.filter(photo_location_filters)
photo_locations = yield query.find()
id_list = [i.photo_id for i in photo_locations]
photo_filters = {}
photo_filters.update({'_id': {'$in': id_list}})
photo_filters.update({
"has_images": True,
"is_hidden": {
"$ne": True
}
})
query = Photo.query.filter(photo_filters).limit(limit)
I lose the order of id_list after $in query. Is there a way to keep the order of id_list in query below?