Mongodb创建索引. 添加唯一索引. ```python from pymongo import MongoClient # 给 coll 的 test_id 字段创建唯一索引 client = MongoClient('host', port=27017) coll = client['db']['coll'] coll.ensure_index('test_id', unique=True) ``` Mongodb创建索引.添加唯一索引.from pymongo import MongoClient # 给 coll 的 test_id 字段创建唯一索引 client = MongoClient('host', port=27017) coll = client['db']['coll'] coll.ensure_index('test_id', unique=True) Last modification:February 21, 2020 © Allow specification reprint Like If you think my article is useful to you, please feel free to appreciate