Created
August 13, 2015 13:49
-
-
Save codedmart/7dce3300c3aac24e344e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- | Per-query settings | |
| data RunFlag = | |
| ReadMode ReadModeOpt | | |
| NoReply | | |
| Durability Durability | | |
| Profile | | |
| ArrayLimit Int | |
| data Durability = Hard | Soft | |
| renderOption :: RunFlag -> (Text, Datum) | |
| renderOption (ReadMode Majority) = "read_mode" .= ("majority" :: String) | |
| renderOption (ReadMode Single) = "read_mode" .= ("single" :: String) | |
| renderOption (ReadMode Outdated) = "read_mode" .= ("outdated" :: String) | |
| renderOption NoReply = "noreply" .= True | |
| renderOption (Durability Soft) = "durability" .= ("soft" :: String) | |
| renderOption (Durability Hard) = "durability" .= ("hard" :: String) | |
| renderOption Profile = "profile" .= True | |
| renderOption (ArrayLimit n) = "array_limit" .= n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data ReadModeOpt = Majority | Single | Outdated | |
| -- | State used to build a Term | |
| data QuerySettings = QuerySettings { | |
| queryToken :: Int64, | |
| queryDefaultDatabase :: Database, | |
| queryVarIndex :: Int, | |
| -- queryUseOutdated :: Maybe Bool <- was this | |
| queryReadMode :: Maybe ReadModeOpt | |
| } | |
| instance Expr Table where | |
| expr (Table mdb name _) = withQuerySettings $ \QuerySettings {..} -> | |
| op' TABLE (fromMaybe queryDefaultDatabase mdb, name) $ catMaybes [ | |
| -- fmap ("use_outdated" :=) queryUseOutdated ] <- was | |
| fmap ("read_mode" :=) queryReadMode ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment