What is the equivalent of the collection.getIndexes() shell command in pymongo?

前端 未结 1 1487
半阙折子戏
半阙折子戏 2021-01-17 10:01

I can\'t seem to find a getIndexes() command implemented as part of pymongo\'s Collection object - is that intentional? is it implemented somewhere else in the class hierarc

相关标签:
1条回答
  • 2021-01-17 10:45

    What you might be looking for is index_information() at the Collection level. From the docs:

    Get information on this collection’s indexes.

    Returns a dictionary where the keys are index names (as returned by create_index()) and the values are dictionaries containing information about each index.

    >>> db.test.index_information()
    {u'_id_': {u'key': [(u'_id', 1)]},
    u'x_1': {u'unique': True, u'key': [(u'x', 1)]}}
    
    0 讨论(0)
提交回复
热议问题