I need to get an array with the values from the field 'colname'. I can't return a Cursor, just the array of values.
Is there a way to query this array without having to loop the Cursor? I feel this is a waste of processing resources.
Right now I'm doing this:
from pymongo import MongoClient
client = MongoClient('mongodb://localhost:27017/')
headers = client['headers']
entomo = headers.entomo
entomo_data = entomo.find()
entomo_array = []
for data in entomo_data:
entomo_array.append(data['colname'])
Then I return the entomo_array
.