* the name of the collection
* @return a table definition for mongo db.
*/
public static SimpleTableDef detectTable(DB db, String collectionName) {
final DBCollection collection = db.getCollection(collectionName);
final DBCursor cursor = collection.find().limit(1000);
final SortedMap<String, Set<Class<?>>> columnsAndTypes = new TreeMap<String, Set<Class<?>>>();
while (cursor.hasNext()) {
DBObject object = cursor.next();
Set<String> keysInObject = object.keySet();