瓶-mongoengine聚合 [英] Aggregation in flask-mongoengine

查看:689
本文介绍了瓶-mongoengine聚合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是盯着MongoDB,而且我正在用flask-mongoengine盯着一个应用程序,我想汇总几个文档。



我正在使用flask-mongoengine,并试图
$ b $ pre $ class $ MyDocumentModel(db.Document)
name = db.StringField(max_length = 55)

MyDocumentModel.objects.aggregate()

:b
$ b


AttributeError:'BaseQuerySet'对象没有'aggregate'属性

$ b $从mongoengine v0.9(目前正在开发中)开始,你将可以使用 aggregate(),就像你建议的那样: http://docs.mongoengine。 org / apireference.html#mongoengine.queryset.QuerySet.aggregate



在此之前,您需要依靠 pymongo Flask-MongoEngine& PyMongo聚合查询


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'

解决方案

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

这篇关于瓶-mongoengine聚合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆