Closed adam-clarey closed 7 years ago
This update adds the Point field type allowing for coordinate fields.
It also makes the dbCollections object global so that it can be used in modules for opperations other than just 'find' like the below example:
var dbConn = iris.dbCollections['forsale']; var aggregateQuery = []; if (params.coordinates) { aggregateQuery.push({ '$geoNear' : { near: { type: 'Point', coordinates: params.coordinates }, spherical: true, maxDistance: 2000, distanceMultiplier: 1, distanceField: 'distanceFromSource' } }); } // Only properties from the last 2 years. params.query['date'] = {$gte: new Date(new Date().setFullYear(new Date().getFullYear() - 2)).toISOString()}; if (params.query) { aggregateQuery.push({ '$match' : params.query }); } var stream = dbConn.aggregate(aggregateQuery).allowDiskUse(true).cursor({ batchSize: 100000 }).exec(); stream .on('data', function(result) { // Do stuff }) .on('end', function() { // Do stuff }) .on('error', function(err) { callback("There was a problem collecting results: " + err.message); });
all good.
i'm not allowed to merge sorry
This update adds the Point field type allowing for coordinate fields.
It also makes the dbCollections object global so that it can be used in modules for opperations other than just 'find' like the below example: