@@ -52,26 +52,28 @@ addHydrateFrom("$lte", makeNew(is.LessThanEqual));
5252
5353addHydrateFromValues ( "$all" , makeNew ( is . All ) ) ;
5454
55- var notRemap = {
56- "LessThan" : { Type : is . GreaterThanEqual , prop : "value" } ,
57- "LessThanEqual" : { Type : is . GreaterThan , prop : "value" } ,
58- "GreaterThan" : { Type : is . LessThanEqual , prop : "value" } ,
59- "GreaterThanEqual" : { Type : is . LessThan , prop : "value" } ,
60- "In" : { Type : is . NotIn , prop : "values" } ,
61- "NotIn" : { Type : is . In , prop : "values" }
55+ // This is a mapping of types to their opposite. The $not hydrator
56+ // uses this to create a more specific type, since they are logical opposites.
57+ var oppositeTypeMap = {
58+ LessThan : { Type : is . GreaterThanEqual , prop : "value" } ,
59+ LessThanEqual : { Type : is . GreaterThan , prop : "value" } ,
60+ GreaterThan : { Type : is . LessThanEqual , prop : "value" } ,
61+ GreaterThanEqual : { Type : is . LessThan , prop : "value" } ,
62+ In : { Type : is . NotIn , prop : "values" } ,
63+ NotIn : { Type : is . In , prop : "values" }
6264} ;
6365
6466hydrateMap [ "$not" ] = function ( value , unknownHydrator ) {
6567 // Many nots can be hydrated to their opposite.
6668 var hydratedValue = hydrateValue ( value [ "$not" ] , unknownHydrator ) ;
6769 var typeName = hydratedValue . constructor . name ;
6870
69- if ( notRemap [ typeName ] ) {
70- var options = notRemap [ typeName ] ;
71- var RemapConstructor = options . Type ;
71+ if ( oppositeTypeMap [ typeName ] ) {
72+ var options = oppositeTypeMap [ typeName ] ;
73+ var OppositeConstructor = options . Type ;
7274 var prop = options . prop ;
7375
74- return new RemapConstructor ( hydratedValue [ prop ] ) ;
76+ return new OppositeConstructor ( hydratedValue [ prop ] ) ;
7577 }
7678
7779 return new ValuesNot ( hydratedValue ) ;
0 commit comments