title: Loopback MongoDB GeoIp 'near' query from angular client
body: <p>I am working with a loopback angular project, mongoDB as database. Searching for nearest user by latitude and longitude in loopback mongoDB query,  using 'near' keyword causing error.  </p>
  
  <p>Note: I indexed 'loc' field in 2d.</p>
  
  <p>Error:</p>
  
  <pre><code>&gt; D:\nodejs\your-time\version_1\node_modules\mongodb\lib\utils.js:98
      process.nextTick(function() { throw err; });
                                    ^
  Error: Can't set headers after they are sent.
      at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:344:11)
      at ServerResponse.header (D:\nodejs\your-time\version_1\node_modules\express
  \lib\response.js:719:10)
      at HttpContext.done (D:\nodejs\your-time\version_1\node_modules\strong-remot
  ing\lib\http-context.js:651:9)
      at D:\nodejs\your-time\version_1\node_modules\strong-remoting\lib\rest-adapt
  er.js:492:11
      at D:\nodejs\your-time\version_1\node_modules\strong-remoting\node_modules\a
  sync\lib\async.js:251:17
      at D:\nodejs\your-time\version_1\node_modules\strong-remoting\node_modules\a
  sync\lib\async.js:154:25
      at D:\nodejs\your-time\version_1\node_modules\strong-remoting\node_modules\a
  sync\lib\async.js:248:21
      at D:\nodejs\your-time\version_1\node_modules\strong-remoting\node_modules\a
  sync\lib\async.js:612:34
      at interceptInvocationErrors (D:\nodejs\your-time\version_1\node_modules\str
  ong-remoting\lib\remote-objects.js:690:22)
      at D:\nodejs\your-time\version_1\node_modules\loopback-phase\node_modules\as
  ync\lib\async.js:154:25
  </code></pre>
  
  <p>And my Code is below:</p>
  
  <pre><code>Profile.find({
      filter: {
          where: {
              type: 'expert',
              is_verified: 1,
              expert_category: $scope.expertCategory,
              loc: {
                  'near': [lat, lng]
              }
          }
      }
  }).$promise.then(function(users) {
      console.log(users);
      $scope.users = users;
  });
  </code></pre>
  
  <p>What am I doing wrong ?</p>