     # find if there is an implicit $and compundQuery operator
     if compoundQuery.length isnt queryKeys.length
       # Add the and compund query operator (with a sanity check that it doesn't exist)
-      if "$and" not in compoundQuery
+      if not utils.includes(compoundQuery, "$and")
         query.$and = {}
         compoundQuery.unshift "$and"
-      for own key, val of query when key not in utils.compoundKeys
+      for own key, val of query when not utils.includes(utils.compundKeys, key)
         query.$and[key] = val
         delete query[key]
     (for type in compoundQuery

    when "$gte"             then value? and attr >= value
    when "$between"         then value[0]? and value[1]? and value[0] < attr < value[1]
    when "$betweene"        then value[0]? and value[1]? and value[0] <= attr <= value[1]
    when "$in"              then attr in value
    when "$nin"             then attr not in value
    when "$all"             then utils.every value, (item) -> item in attr
    when "$any"             then utils.some attr, (item) -> item in value
    when "$size"            then attr.length is value
    when "$exists", "$has"  then attr? is value
    when "$like"            then attr.indexOf(value) isnt -1

    (item for item in array1 when array2.indexOf(item) isnt -1)

  out.isEqual = (a,b) -> JSON.stringify(a) is JSON.stringify(b)

  out.includes = (a, b) -> b in a
  out


