@@ -52,26 +52,28 @@ addHydrateFrom("$lte", makeNew(is.LessThanEqual));
52
52
53
53
addHydrateFromValues ( "$all" , makeNew ( is . All ) ) ;
54
54
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" }
62
64
} ;
63
65
64
66
hydrateMap [ "$not" ] = function ( value , unknownHydrator ) {
65
67
// Many nots can be hydrated to their opposite.
66
68
var hydratedValue = hydrateValue ( value [ "$not" ] , unknownHydrator ) ;
67
69
var typeName = hydratedValue . constructor . name ;
68
70
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 ;
72
74
var prop = options . prop ;
73
75
74
- return new RemapConstructor ( hydratedValue [ prop ] ) ;
76
+ return new OppositeConstructor ( hydratedValue [ prop ] ) ;
75
77
}
76
78
77
79
return new ValuesNot ( hydratedValue ) ;
0 commit comments