浏览代码

Added 'map' and 'aggregate' extension functions to our view templates. Fixed an issue with munge where exclusion was not working. fixes #1653

http://source.rd.rcg.local/trac/eagle6/changeset/1395/Eagle6_SVN
Philip Murray 12 年之前
父节点
当前提交
89b46757f0
共有 2 个文件被更改,包括 17 次插入1 次删除
  1. 1 1
      lib/pipeline/expressions/Expression.js
  2. 16 0
      test/lib/munge.js

+ 1 - 1
lib/pipeline/expressions/Expression.js

@@ -232,7 +232,7 @@ var Expression = module.exports = (function(){
 						exprObj.includePath(fn);
 					} else {
 						if (!(ctx.isTopLevel && fn == Document.ID_PROPERTY_NAME)) throw new Error("The top-level " + Document.ID_PROPERTY_NAME + " field is the only field currently supported for exclusion; code 16406");
-						exprObj.excludeId(true);
+						exprObj.excludeId = true;
 					}
 					break;
 				default:

+ 16 - 0
test/lib/munge.js

@@ -107,6 +107,22 @@ module.exports = {
 			assert.deepEqual(munger(i), e, "Reuse of munger should yield the same results!");
 			assert.deepEqual(munge(p, i), e, "Alternate use of munge should yield the same results!");
 		},
+		
+		
+		"should be able to use a $project operator to exclude the _id field": function(){
+			var i = [{_id:0, e:1, f:23}, {_id:2, e:2, g:34}, {_id:4, e:3}],
+				p = [{$project:{
+						_id:0,
+						e:1
+						//TODO: high level test of all other expression operators
+					}}],
+				e = [{e:1}, {e:2}, {e:3}],
+				munger = munge(p),
+				a = munger(i);
+			assert.deepEqual(a, e, "Unexpected value (not deepEqual)!");
+			assert.deepEqual(munger(i), e, "Reuse of munger should yield the same results!");
+			assert.deepEqual(munge(p, i), e, "Alternate use of munge should yield the same results!");
+		},
 
 		"should be able to construct an instance with $sort operators properly (ascending)": function(){
 			var i = [