Browse Source

refs #5133: minor change to geonear doc source

Patrick Rigney 11 years ago
parent
commit
3be52d35db

+ 3 - 3
lib/pipeline/documentSources/GeoNearDocumentSource.js

@@ -39,7 +39,7 @@ proto.setSource = function(docSource) {
 	throw new Error('code 16602; $geoNear is only allowed as the first pipeline stage');
 };
 
-proto.isValidInitialSource = function() { 
+proto.isValidInitialSource = function() {
 	return true;
 };
 
@@ -91,11 +91,11 @@ klass.createFromJson = function(jsonElement, ctx) {
 };
 
 proto.parseOptions = function(options) {
-	
+
 	// near and distanceField are required
 	if (!options.near || !Array.isArray(options.near))
 		throw new Error('code 16605; $geoNear requires a \'near\' option as an Array');
-	this.coordsIsArray = options.near instanceof Array; // TODO: array? object?
+	this.coordsIsArray = options.near instanceof Array;
 
 	if (typeof options.distanceField !== 'string')
 		throw new Error('code 16606: $geoNear  a \'distanceNear\' option as a String');

+ 6 - 7
test/lib/pipeline/documentSources/GeoNearDocumentSource.js

@@ -71,7 +71,7 @@ module.exports = {
 		"#createFromJson()":{
 
 			"method creates GeoNearDocumentSource with appropriate options":function() {
-				var optsObj = {
+				var opts = {
 						// example options
 						near:[40.724, -73.997],
 						limit:25,
@@ -81,15 +81,14 @@ module.exports = {
 						uniqueDocs:true,
 						includeLocs:"dist.location"
 					},
-					optsStr = JSON.stringify(optsObj),
-					gnds = GeoNearDocumentSource.createFromJson(optsStr);
+					gnds = GeoNearDocumentSource.createFromJson(opts);
 
 				assert.equal(gnds.source, null);
-				assert.equal(gnds.limit, optsObj.limit);
-				assert.deepEqual(gnds.query, optsObj.query);
+				assert.equal(gnds.limit, opts.limit);
+				assert.deepEqual(gnds.query, opts.query);
 				assert.ok(gnds.distanceField instanceof FieldPath);
-				assert.equal(gnds.maxDistance, optsObj.maxDistance);
-				assert.equal(gnds.uniqueDocs, optsObj.uniqueDocs);
+				assert.equal(gnds.maxDistance, opts.maxDistance);
+				assert.equal(gnds.uniqueDocs, opts.uniqueDocs);
 				assert.ok(gnds.includeLocs instanceof FieldPath);
 			}
 		}