title: Mongodb Query error
body: <p>I have a collection named Configuration, configuration has a osType, I want to calculate all osType and group by on company I am using this solution </p>
  
  <pre><code>return Configuration.distinct("osType").then(function (name) {
    var types = name
  
    var groupObj = {"$group": {"_id": "$company.name"}},
      projectObj = {"$project": {"_id": 0, "Company": "$_id.company"}};
  
    var groupPipeline = types.reduce(function (obj, type) { // set the group pipeline object
      obj["$group"][type + "_count"] = {
        "$sum": {
          "$cond": [{"$eq": ["$type", type]}, 1, 0]
        }
      };
      return obj;
    }, groupObj);
  
    return Configuration.aggregate([groupPipeline]).then(function (result) {
      return {status: true, code: 200, message: "Configuration count", data: result}
    });
  </code></pre>
  
  <p>I am getting this error </p>
  
  <pre><code>"message": "exception: the group aggregate field name '8.1_count' cannot be used because $group's field names cannot contain '.'",
  </code></pre>
  
  <p>This is my sample document </p>
  
  <pre><code>{
    "_id" : ObjectId("57c97bd6ad85bac155aecafb"),
    "ITBConfigurationId" : 26921,
    "updatedAt" : ISODate("2016-09-02T13:17:10.066Z"),
    "createdAt" : ISODate("2016-09-02T13:17:10.066Z"),
    "id" : "23",
    "name" : "dav20-pc-126.dallas.dav20.thd",
    "type" : "Managed Workstation",
    "locationId" : null,
    "osType" : "7",
    "osInfo" : "Home Premium x64 Edition Service Pack 1 Build 7601",
    "company" : {
      "id" : 19300,
      "identifier" : "DAV20",
      "name" : "Davidson Stewart Morelock Ind Ins Group, LLC"
    },
    "__v" : 0
  }
  </code></pre>
  
  <p>and distinct list of osType</p>
  
  <pre><code>[ '7',
   'Mac OS X',
   '8.1',
   'Vista',
   'XP',
   '2003',
   '2008',
   '2012',
   '8',
   'Linux',
   'Microsoft Windows Server 2012 R2 Datacenter x64',
   'Microsoft Windows Server 2012 R2 Standard x64',
   'Microsoft Windows 7 Professional  x64',
   '',
   '2000',
   'Microsoft Windows 7 Professional ',
   'Microsoft Windows 10 Pro x64',
   'Darwin',
   'Microsoft Windows Server 2012 Standard x64',
   'Microsoft Windows Server 2008 R2 Standard  x64',
   'Microsoft Windows XP Professional',
   'Microsoft Windows 8.1 Pro x64',
   'Microsoft® Windows Vista™ Home Premium  x64',
   'Microsoft Windows Server 2012 Datacenter x64',
   'Microsoft Windows Server 2003 for Small Business Server',
   'Microsoft® Windows Vista™ Business ',
   'Microsoft Windows 7 Home Premium  x64',
   'Microsoft Windows XP Home Edition',
   'Microsoft Windows 8 Pro x64',
   'Microsoft Windows 7 Home Premium ',
   'Microsoft Windows 8.1 x64',
   'Microsoft Windows 10 Home x64',
   'Microsoft Windows 8.1 Pro with Media Center x64',
   'Microsoft Windows 10 Pro' 
  ]
  </code></pre>