{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ConstraintKinds #-}

module Prolude.MongoDB
  ( module Database.MongoDB
  , MongoAction
  , MongoCollection
  , MongoDatabase
  , MongoDocument
  , MongoField
  , MongoLabel
  , MongoQuery
  , MongoValue
  , MongoVal
  , pattern MongoArray
  , pattern MongoBin
  , pattern MongoBool
  , pattern MongoDoc
  , pattern MongoFloat
  , pattern MongoFun
  , pattern MongoInt32
  , pattern MongoInt64
  , pattern MongoJavaScr
  , pattern MongoMd5
  , pattern MongoMinMax
  , pattern MongoNull
  , pattern MongoObjId
  , pattern MongoRegEx
  , pattern MongoStamp
  , pattern MongoString
  , pattern MongoSym
  , pattern MongoUserDef
  , pattern MongoUTC
  , pattern MongoUuid
  , mongoFailed
  , mongoInsert_
  , mongoModified
  , mongoSelect
  , mongoUpdateMany
  )
where

import Prolude.Core

import Control.Monad.IO.Class (MonadIO)
import Database.MongoDB (ObjectId, UpdateOption(MultiUpdate), fval, genObjectId, (=:))
import qualified Data.Int as Int
import qualified Data.Text as Text
import qualified Data.Time as Time
import qualified Database.MongoDB as Mongo

type MongoAction = Mongo.Action
type MongoCollection = Mongo.Collection
type MongoDatabase = Mongo.Database
type MongoDocument = Mongo.Document
type MongoField = Mongo.Field
type MongoLabel = Mongo.Label
type MongoQuery = Mongo.Query
type MongoSelector = Mongo.Selector
type MongoVal = Mongo.Val

type MongoValue = Mongo.Value

pattern MongoFloat :: Double -> MongoValue
pattern $bMongoFloat :: Double -> MongoValue
$mMongoFloat :: forall r. MongoValue -> (Double -> r) -> (Void# -> r) -> r
MongoFloat x = Mongo.Float x

pattern MongoString :: Text.Text -> MongoValue
pattern $bMongoString :: Text -> MongoValue
$mMongoString :: forall r. MongoValue -> (Text -> r) -> (Void# -> r) -> r
MongoString x = Mongo.String x

pattern MongoDoc :: Mongo.Document -> MongoValue
pattern $bMongoDoc :: Document -> MongoValue
$mMongoDoc :: forall r. MongoValue -> (Document -> r) -> (Void# -> r) -> r
MongoDoc x = Mongo.Doc x

pattern MongoArray :: [Mongo.Value] -> MongoValue
pattern $bMongoArray :: [MongoValue] -> MongoValue
$mMongoArray :: forall r. MongoValue -> ([MongoValue] -> r) -> (Void# -> r) -> r
MongoArray x = Mongo.Array x

pattern MongoBin :: Mongo.Binary -> MongoValue
pattern $bMongoBin :: Binary -> MongoValue
$mMongoBin :: forall r. MongoValue -> (Binary -> r) -> (Void# -> r) -> r
MongoBin x = Mongo.Bin x

pattern MongoFun :: Mongo.Function -> MongoValue
pattern $bMongoFun :: Function -> MongoValue
$mMongoFun :: forall r. MongoValue -> (Function -> r) -> (Void# -> r) -> r
MongoFun x = Mongo.Fun x

pattern MongoUuid :: Mongo.UUID -> MongoValue
pattern $bMongoUuid :: UUID -> MongoValue
$mMongoUuid :: forall r. MongoValue -> (UUID -> r) -> (Void# -> r) -> r
MongoUuid x = Mongo.Uuid x

pattern MongoMd5 :: Mongo.MD5 -> MongoValue
pattern $bMongoMd5 :: MD5 -> MongoValue
$mMongoMd5 :: forall r. MongoValue -> (MD5 -> r) -> (Void# -> r) -> r
MongoMd5 x = Mongo.Md5 x

pattern MongoUserDef :: Mongo.UserDefined -> MongoValue
pattern $bMongoUserDef :: UserDefined -> MongoValue
$mMongoUserDef :: forall r. MongoValue -> (UserDefined -> r) -> (Void# -> r) -> r
MongoUserDef x = Mongo.UserDef x

pattern MongoObjId :: Mongo.ObjectId -> MongoValue
pattern $bMongoObjId :: ObjectId -> MongoValue
$mMongoObjId :: forall r. MongoValue -> (ObjectId -> r) -> (Void# -> r) -> r
MongoObjId x = Mongo.ObjId x

pattern MongoBool :: Bool -> MongoValue
pattern $bMongoBool :: Bool -> MongoValue
$mMongoBool :: forall r. MongoValue -> (Bool -> r) -> (Void# -> r) -> r
MongoBool x = Mongo.Bool x

pattern MongoUTC :: Time.UTCTime -> MongoValue
pattern $bMongoUTC :: UTCTime -> MongoValue
$mMongoUTC :: forall r. MongoValue -> (UTCTime -> r) -> (Void# -> r) -> r
MongoUTC x = Mongo.UTC x

pattern MongoNull :: MongoValue
pattern $bMongoNull :: MongoValue
$mMongoNull :: forall r. MongoValue -> (Void# -> r) -> (Void# -> r) -> r
MongoNull = Mongo.Null

pattern MongoRegEx :: Mongo.Regex -> MongoValue
pattern $bMongoRegEx :: Regex -> MongoValue
$mMongoRegEx :: forall r. MongoValue -> (Regex -> r) -> (Void# -> r) -> r
MongoRegEx x = Mongo.RegEx x

pattern MongoJavaScr :: Mongo.Javascript -> MongoValue
pattern $bMongoJavaScr :: Javascript -> MongoValue
$mMongoJavaScr :: forall r. MongoValue -> (Javascript -> r) -> (Void# -> r) -> r
MongoJavaScr x = Mongo.JavaScr x

pattern MongoSym :: Mongo.Symbol -> MongoValue
pattern $bMongoSym :: Symbol -> MongoValue
$mMongoSym :: forall r. MongoValue -> (Symbol -> r) -> (Void# -> r) -> r
MongoSym x = Mongo.Sym x

pattern MongoInt32 :: Int.Int32 -> MongoValue
pattern $bMongoInt32 :: Int32 -> MongoValue
$mMongoInt32 :: forall r. MongoValue -> (Int32 -> r) -> (Void# -> r) -> r
MongoInt32 x = Mongo.Int32 x

pattern MongoInt64 :: Int.Int64 -> MongoValue
pattern $bMongoInt64 :: Int64 -> MongoValue
$mMongoInt64 :: forall r. MongoValue -> (Int64 -> r) -> (Void# -> r) -> r
MongoInt64 x = Mongo.Int64 x

pattern MongoStamp :: Mongo.MongoStamp -> MongoValue
pattern $bMongoStamp :: MongoStamp -> MongoValue
$mMongoStamp :: forall r. MongoValue -> (MongoStamp -> r) -> (Void# -> r) -> r
MongoStamp x = Mongo.Stamp x

pattern MongoMinMax :: Mongo.MinMaxKey -> MongoValue
pattern $bMongoMinMax :: MinMaxKey -> MongoValue
$mMongoMinMax :: forall r. MongoValue -> (MinMaxKey -> r) -> (Void# -> r) -> r
MongoMinMax x = Mongo.MinMax x

{-# COMPLETE
  MongoFloat
  , MongoString
  , MongoDoc
  , MongoArray
  , MongoBin
  , MongoFun
  , MongoUuid
  , MongoMd5
  , MongoUserDef
  , MongoObjId
  , MongoBool
  , MongoUTC
  , MongoNull
  , MongoRegEx
  , MongoJavaScr
  , MongoSym
  , MongoInt32
  , MongoInt64
  , MongoStamp
  , MongoMinMax #-}

mongoFailed :: Mongo.WriteResult -> Bool
mongoFailed :: WriteResult -> Bool
mongoFailed = WriteResult -> Bool
Mongo.failed

mongoInsert_ :: MonadIO m => MongoCollection -> MongoDocument -> MongoAction m ()
mongoInsert_ :: Text -> Document -> MongoAction m ()
mongoInsert_ = Text -> Document -> MongoAction m ()
forall (m :: * -> *). MonadIO m => Text -> Document -> Action m ()
Mongo.insert_

mongoModified :: Mongo.WriteResult -> Maybe Int
mongoModified :: WriteResult -> Maybe Int
mongoModified = WriteResult -> Maybe Int
Mongo.nModified

mongoSelect :: MongoSelector -> MongoCollection -> MongoQuery
mongoSelect :: Document -> Text -> MongoQuery
mongoSelect = Document -> Text -> MongoQuery
forall aQueryOrSelection.
Select aQueryOrSelection =>
Document -> Text -> aQueryOrSelection
Mongo.select

mongoUpdateMany
  :: MonadIO m
  => MongoCollection
  -> [(MongoSelector, MongoDocument, [UpdateOption])]
  -> MongoAction m Mongo.WriteResult
mongoUpdateMany :: Text
-> [(Document, Document, [UpdateOption])]
-> MongoAction m WriteResult
mongoUpdateMany = Text
-> [(Document, Document, [UpdateOption])]
-> MongoAction m WriteResult
forall (m :: * -> *).
MonadIO m =>
Text
-> [(Document, Document, [UpdateOption])] -> Action m WriteResult
Mongo.updateMany