I've been trying to understand how to transform a Data type into a Document with Haskell's Data.Bson.Mapping package, however, I couldn't figure it out and the example in the docs didn't help much either.
How should I resolve this problem? No questions regarding this seem to have been posted yet. I'll attach relevant code below, so you may be able to understand where I'm coming from.
{-# LANGUAGE TemplateHaskell #-}
module Main where
import Database.MongoDB.Connection (host, connect)
import Database.MongoDB.Query (access, master, insertMany)
import Data.Data (Typeable)
import Data.Bson.Mapping
data Item a = Item { content :: a
, checked :: Bool
} deriving (Eq, Show, Typeable)
What I've tried so far
- selectFields, but I don't know how to change the Expression (Q Exp) into a Document
- Implementing deriveBson, but I got the same error as with the example from the Docs
Please note, I'm still fairly new to Haskell and I have spent 2 hours looking for a solution, but just couldn't figure it out.
Thank you.