Aggregation in flask-mongoengine

孤街醉人 提交于 2019-12-12 15:43:38

问题


I'm just staring out with MongoDB and I'm staring an application with flask-mongoengine and I want to aggregate a few documents.

I'm using flask-mongoengine and when trying

class MyDocumentModel(db.Document):
  name = db.StringField(max_length=55)

MyDocumentModel.objects.aggregate()

I get the error:

AttributeError: 'BaseQuerySet' object has no attribute 'aggregate'


回答1:


Starting with mongoengine v0.9 (which is currently in development), you will be able to use aggregate(), like you suggested: http://docs.mongoengine.org/apireference.html#mongoengine.queryset.QuerySet.aggregate

Until then, you need to rely on pymongo: Flask-MongoEngine & PyMongo Aggregation Query



来源:https://stackoverflow.com/questions/19954830/aggregation-in-flask-mongoengine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!