index = self.xiaoMiQuanCollection.createIndex({"unique_charcter": 1, "name": 'hashed'}, {"unique": True})
res = self.xiaoMiQuanCollection.find(index)
TypeError: 'Collection' object is not callable. If you meant to call the 'createIndex' method on a 'Collection' object it is failing because no such method exists.
我写ensureIndex 也不对,求指教### 题目描述
self是什么类型?除非self继承了database否则不会直接取到collection。就算是,那语法也应该是:
self["xiaoMiQuanCollection"].createIndex(...)
先看看文档学学基本操作:http://api.mongodb.com/python...