command cursor' object is not subscriptable

前端 未结 1 922
栀梦
栀梦 2021-01-19 16:33

I\'m new in Python and MongoDB and I am starting a new project with flask-python and MongoDB. When I try returning data using the aggregate() function, it gives

相关标签:
1条回答
  • 2021-01-19 17:22

    Since Pymongo 3.0, the .aggregate() method return a CommandCursor which doesn't implement the __getitem__() method. Instead I suggest you return the cursor object in your function/method or turn to result into a list like this: return list(Data)

    0 讨论(0)
提交回复
热议问题