{-# LANGUAGE FlexibleInstances, OverloadedStrings #-}

module Data.Document (
        FromDocument (..)
        , ToDocument (..)
        ) where

import qualified Database.MongoDB as D 
import qualified Data.Time.Clock as T

class FromDocument a where
    fromDocument :: D.Document -> a

instance FromDocument a => FromDocument (a, T.UTCTime) where
    fromDocument d = (fromDocument d, D.timestamp $ D.typed $ D.valueAt "_id" d)

class ToDocument a where
    toDocument :: a -> D.Document
