fixes for query opts

This commit is contained in:
Scott R. Parish 2010-01-14 07:04:24 -06:00
parent f9b4076a5c
commit 985423cfe7

View file

@ -81,13 +81,13 @@ type RequestID = Int32
type NumToSkip = Int32 type NumToSkip = Int32
type NumToReturn = Int32 type NumToReturn = Int32
data QueryOpts = QO_TailableCursor data QueryOpt = QO_TailableCursor
| QO_SlaveOK | QO_SlaveOK
| QO_OpLogReplay | QO_OpLogReplay
| QO_NoCursorTimeout | QO_NoCursorTimeout
deriving (Show) deriving (Show)
fromQueryOpts [opts] = List.foldl (.|.) 0 $ fmap toVal opts fromQueryOpts opts = List.foldl (.|.) 0 $ fmap toVal opts
where toVal QO_TailableCursor = 2 where toVal QO_TailableCursor = 2
toVal QO_SlaveOK = 4 toVal QO_SlaveOK = 4
toVal QO_OpLogReplay = 8 toVal QO_OpLogReplay = 8
@ -126,11 +126,11 @@ insertMany c col docs = do
L.hPut (cHandle c) msg L.hPut (cHandle c) msg
return reqID return reqID
query :: Connection -> Collection -> [QueryOpts] -> NumToSkip -> NumToReturn -> query :: Connection -> Collection -> [QueryOpt] -> NumToSkip -> NumToReturn ->
Selector -> Maybe FieldSelector -> IO [BSONObject] Selector -> Maybe FieldSelector -> IO [BSONObject]
query c col opts skip ret sel fsel = do query c col opts skip ret sel fsel = do
let body = runPut $ do let body = runPut $ do
putI32 0 -- TODO opts putI32 $ fromQueryOpts opts
putCol col putCol col
putI32 skip putI32 skip
putI32 ret putI32 ret