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
评论列表
文章目录