Pymongo / MongoDB: create index or ensure index?

后端 未结 5 2060
温柔的废话
温柔的废话 2020-12-07 22:30

I don\'t understand the difference between create_index and ensure_index in pymongo. On the MongoDB indexes page, it says

yo

5条回答
  •  温柔的废话
    2020-12-07 22:44

    I would recommend creating metaclass and ORM. From metaclass init call init_schema method for initializing the counters, schema, keys etc. This way you prevent calling ensure_index every query or collection update :)

提交回复
热议问题