You don't need .toMap() here. keySet() is a method on DBObject