-- | Like '(==.)' but for an embedded list.
-- Checks to see if the list contains an item.
--
-- In Haskell we need different equality functions for embedded fields that are lists or non-lists to keep things type-safe.
--
-- using this as the only query filter is similar to the following in the mongoDB shell
--
-- > db.Collection.find({arrayField: arrayItem})
anyEq :: forall record typ.
        ( PersistField typ
        , PersistEntityBackend record ~ DB.MongoContext
        ) => EntityField record [typ] -> typ -> Filter record
fld `anyEq` val = BackendFilter $
    ArrayFilter fld $ PersistFilterOperator (Left val) Eq
anyEq :: forall record typ.
        ( PersistField typ
        , PersistEntityBackend record ~ DB.MongoContext
        ) => EntityField record [typ] -> typ -> Filter record
fld `anyEq` val = BackendFilter $
    ArrayFilter fld $ PersistFilterOperator (Left val) Eq
fld `anyEq` val = BackendFilter $
    ArrayFilter fld $ PersistFilterOperator (Left val) Eq