Function eval returns Val v instead of Document

Fixes #1
This commit is contained in:
Fedor Gogolev 2012-07-09 08:26:58 +04:00
parent a6ecd104f7
commit 4ae4f793e3

View file

@ -60,8 +60,9 @@ import Control.Monad.Trans.Control (ComposeSt, MonadBaseControl(..),
MonadTransControl(..), StM, StT, MonadTransControl(..), StM, StT,
defaultLiftBaseWith, defaultRestoreM) defaultLiftBaseWith, defaultRestoreM)
import Control.Monad.Writer (WriterT, Monoid) import Control.Monad.Writer (WriterT, Monoid)
import Data.Bson (Document, Field(..), Label, Value(String,Doc), Javascript, import Data.Bson (Document, Field(..), Label, Val, Value(String,Doc),
at, valueAt, lookup, look, genObjectId, (=:), (=?)) Javascript, at, valueAt, lookup, look, genObjectId, (=:),
(=?))
import Data.Text (Text) import Data.Text (Text)
import qualified Data.Text as T import qualified Data.Text as T
@ -694,7 +695,7 @@ runCommand1 :: (MonadIO' m) => Text -> Action m Document
-- ^ @runCommand1 foo = runCommand [foo =: 1]@ -- ^ @runCommand1 foo = runCommand [foo =: 1]@
runCommand1 c = runCommand [c =: (1 :: Int)] runCommand1 c = runCommand [c =: (1 :: Int)]
eval :: (MonadIO' m) => Javascript -> Action m Document eval :: (MonadIO' m, Val v) => Javascript -> Action m v
-- ^ Run code on server -- ^ Run code on server
eval code = at "retval" <$> runCommand ["$eval" =: code] eval code = at "retval" <$> runCommand ["$eval" =: code]