mongo.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:database_assetstore 作者: OpenGeoscience 项目源码 文件源码
def getFieldInfo(self):
        """
        Return a list of fields that are known and can be queried.

        :return: a list of known fields.  Each entry is a dictionary with name,
                 datatype, and optionally a description.
        """
        if self.fieldInfo is None:
            # cache the fieldInfo so we don't process all of the documents
            # every time.
            # TODO: either have a maximum duration or some other method of
            # analyzing a subset of the table; on a large table this takes a
            # long time.
            coll = self.connect()

            fields = {}
            for result in coll.find():
                fields.update(result)

            fieldInfo = []
            for field in sorted(six.iterkeys(fields)):
                fieldInfo.append({'name': field,
                                  'type': 'unknown'})
            self.fieldInfo = fieldInfo
        return self.fieldInfo
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号