How does pymongo extract all keys stored in the order in which the document field in the database is stored?

  mongodb, question

RT.
Recently, when doing data preprocessing, I want to use a list to store all the keys in the code, and then pass in the subscript of the specified column to extract the field information of the corresponding entry. The order of keys in the list is preferably fixed, for example, the order in which document store keys in mongodb. Since the relevant methods such as find_one return the dict type, it is out of order. What method is there to extract all keys and store them in the order in which they are stored in the database?

Note that JSON’s definition of key-value pairs is inherently unordered, and the database does not guarantee that BSON objects must be stored in any order. So don’t rely on this order to do anything.