structured-mongoDB-0.3: Structured MongoDB interface

Safe HaskellTrustworthy

Database.MongoDB.Structured.Types

Contents

Description

This module exports a Structued type class which can be used to convert Haskel "record types" to BSON objects and vice versa. As a Mongo document has an "_id" field, we impose the requirement a record type have a field whose type is SObjId (corresponding to "_id").

Synopsis

Documentation

class Structured a whereSource

Structured class used to convert between a Haskell record type and BSON document.

Methods

collectionSource

Arguments

:: a 
-> Collection

Collection name is then name of type

toBSONSource

Arguments

:: a 
-> Document

Convert record to a BSON object

fromBSONSource

Arguments

:: Document 
-> Maybe a

Convert BSON object to record

Structured "_id"

newtype SObjId Source

Type corresponding to the "_id" field of a document in a structured object.

Constructors

SObjId (Maybe ObjectId) 

noSObjId :: SObjIdSource

The "_id" field is unset.

isNoSObjId :: SObjId -> BoolSource

Check if the "_id" field is unset.

toSObjId :: ObjectId -> SObjIdSource

Set the "_id" field.

unSObjId :: SObjId -> ObjectIdSource

Get the "_id" field (assumes that it is set0.