module Database.RethinkDB.Objects (
Database(..),
TableCreateOptions(..),
IndexCreateOptions(..),
Table(..),
Datum,
Key
) where
import Data.Default (def, Default)
import Data.Int (Int64)
import Data.Text as Text
import Data.Aeson (Value)
type Key = Text
data Database = Database {
databaseName :: Text
} deriving (Eq, Ord)
instance Show Database where
show (Database d) = show d
data TableCreateOptions = TableCreateOptions {
tableDataCenter :: Maybe Text,
tableCacheSize :: Maybe Int64
}
instance Default TableCreateOptions where
def = TableCreateOptions Nothing Nothing
data IndexCreateOptions = IndexCreateOptions {
indexMulti :: Maybe Bool
}
instance Default IndexCreateOptions where
def = IndexCreateOptions Nothing
data Table = Table {
tableDatabase :: Maybe Database,
tableName :: Text,
tablePrimaryKey :: Maybe Key
} deriving (Eq, Ord)
instance Show Table where
show (Table db' nam mkey) =
maybe "" (\(Database d) -> Text.unpack d++".") db' ++ Text.unpack nam ++
maybe "" (\k -> "[" ++ show k ++ "]") mkey
type Datum = Value