-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A driver for MongoDB -- -- This driver lets you connect to MongoDB, do inserts, queries, updates, -- etc. Also has many convience functions inspired by HDBC such as more -- easily converting between the BsonValue types and native Haskell -- types. @package mongoDB @version 0.1 module Database.MongoDB.BSON -- | BsonValue is the type that can be used as a key in a BsonDoc. data BsonValue BsonDouble :: Double -> BsonValue BsonString :: ByteString -> BsonValue BsonObject :: BsonDoc -> BsonValue BsonArray :: [BsonValue] -> BsonValue BsonUndefined :: BsonValue BsonBinary :: BinarySubType -> ByteString -> BsonValue BsonObjectId :: ByteString -> BsonValue BsonBool :: !Bool -> BsonValue BsonDate :: POSIXTime -> BsonValue BsonNull :: BsonValue BsonRegex :: ByteString -> String -> BsonValue BsonSymbol :: ByteString -> BsonValue BsonInt32 :: Int32 -> BsonValue BsonInt64 :: Int64 -> BsonValue BsonMinKey :: BsonValue BsonMaxKey :: BsonValue -- | BSON Document: this is the top-level (but recursive) type that all -- MongoDB collections work in terms of. It is a mapping between strings -- (Data.ByteString.Lazu.UTF8.ByteString) and BsonValues. -- It can be constructed either from a Map (eg -- BsonDoc myMap) or from a associative list (eg -- toBsonDoc myAL). newtype BsonDoc BsonDoc :: Map ByteString BsonValue -> BsonDoc bdFromBsonDoc :: BsonDoc -> Map ByteString BsonValue -- | Construct a BsonDoc from an associative list toBsonDoc :: (BsonDocOps a) => [(a, BsonValue)] -> BsonDoc data BinarySubType BSTUNDEFINED_1 :: BinarySubType BSTFunction :: BinarySubType BSTByteArray :: BinarySubType BSTUUID :: BinarySubType BSTUNDEFINED_2 :: BinarySubType BSTMD5 :: BinarySubType BSTUserDefined :: BinarySubType -- | An empty BsonDoc empty :: BsonDoc -- | Return the BsonValue for given key, if any. lookup :: (BsonDocOps a) => a -> BsonDoc -> Maybe BsonValue -- | Convert a BsonValue into a native Haskell type. fromBson :: (BsonConv a b, Convertible a b) => a -> b -- | Convert a native Haskell type into a BsonValue. toBson :: (BsonConv a b, Convertible b a) => b -> a instance Show BinarySubType instance Read BinarySubType instance Enum BinarySubType instance Eq BinarySubType instance Ord BinarySubType instance Show DataType instance Read DataType instance Enum DataType instance Eq DataType instance Ord DataType instance Eq BsonDoc instance Ord BsonDoc instance Show BsonDoc instance Show BsonValue instance Eq BsonValue instance Ord BsonValue instance (Convertible BsonValue a) => Convertible (Maybe BsonValue) (Maybe a) instance Convertible BsonValue Int64 instance Convertible BsonValue Int32 instance Convertible BsonValue Integer instance Convertible BsonValue Int instance Convertible BsonValue POSIXTime instance Convertible BsonValue Bool instance Convertible BsonValue [Int64] instance Convertible BsonValue [Int32] instance Convertible BsonValue [POSIXTime] instance Convertible BsonValue [Bool] instance Convertible BsonValue [String] instance Convertible BsonValue [Float] instance Convertible BsonValue [Double] instance Convertible BsonValue ByteString instance Convertible BsonValue ByteString instance Convertible BsonValue String instance Convertible BsonValue Float instance Convertible BsonValue Double instance (Convertible a BsonValue) => Convertible (Maybe a) BsonValue instance Convertible Int64 BsonValue instance Convertible Int32 BsonValue instance Convertible Integer BsonValue instance Convertible Int BsonValue instance Convertible Bool BsonValue instance Convertible POSIXTime BsonValue instance Convertible [Int64] BsonValue instance Convertible [Int32] BsonValue instance Convertible [Integer] BsonValue instance Convertible [Int] BsonValue instance Convertible [POSIXTime] BsonValue instance Convertible [Bool] BsonValue instance Convertible [ByteString] BsonValue instance Convertible [ByteString] BsonValue instance Convertible [String] BsonValue instance Convertible [Float] BsonValue instance Convertible [Double] BsonValue instance Convertible ByteString BsonValue instance Convertible ByteString BsonValue instance Convertible String BsonValue instance Convertible Float BsonValue instance Convertible Double BsonValue instance BsonConv (Maybe BsonValue) (Maybe a) instance BsonConv BsonValue a instance Binary BsonDoc instance BsonDocOps String instance BsonDocOps ByteString instance Typeable BsonValue module Database.MongoDB -- | A handle to a database connection data Connection -- | Estabilish a connection to a MongoDB server connect :: HostName -> IO Connection -- | Estabilish a connection to a MongoDB server on a non-standard port connectOnPort :: HostName -> PortID -> IO Connection -- | Close database connection conClose :: Connection -> IO () -- | Alias for conClose disconnect :: Connection -> IO () -- | Drop a database. dropDatabase :: Connection -> Database -> IO () -- | The name of a database. type Database = String data MongoDBCollectionInvalid data ColCreateOpt -- | Desired initial size for the collection (in bytes). must be less than -- or equal to 10000000000. For capped collections this size is the max -- size of the collection. CCOSize :: Int64 -> ColCreateOpt -- | If True, this is a capped collection. CCOCapped :: Bool -> ColCreateOpt -- | Maximum number of objects if capped. CCOMax :: Int64 -> ColCreateOpt -- | Return a list of collections in Database. collectionNames :: Connection -> Database -> IO [Collection] -- | Create a new collection in this database. -- -- Normally collection creation is automatic. This function should only -- be needed if you want to specify ColCreateOpts on creation. -- MongoDBCollectionInvalid is thrown if the collection already -- exists. createCollection :: Connection -> Collection -> [ColCreateOpt] -> IO () -- | Drop a collection. dropCollection :: Connection -> Collection -> IO () -- | Return a string of validation info about the collection. -- -- Example output (note this probably can/will change with different -- versions of the server): -- --
--   validate
--    details: 0x7fe5cc2c1da4 ofs:e7da4
--    firstExtent:0:24100 ns:test.foo.bar
--    lastExtent:0:24100 ns:test.foo.bar
--    # extents:1
--    datasize?:180 nrecords?:5 lastExtentSize:1024
--    padding:1
--    first extent:
--      loc:0:24100 xnext:null xprev:null
--      nsdiag:test.foo.bar
--      size:1024 firstRecord:0:241e4 lastRecord:0:24280
--    5 objects found, nobj:5
--    260 bytes data w/headers
--    180 bytes data wout/headers
--    deletedList: 0100100000000000000
--    deleted: n: 4 size: 588
--    nIndexes:1
--      test.foo.bar.$_id_ keys:5
--   
validateCollection :: Connection -> Collection -> IO String -- | The full collection name. The full collection name is the -- concatenation of the database name with the collection name, using a -- . for the concatenation. For example, for the database -- foo and the collection bar, the full collection name -- is foo.bar. type Collection = String -- | A list of field names that limits the fields in the returned -- documents. The list can contains zero or more elements, each of which -- is the name of a field that should be returned. An empty list means -- that no limiting is done and all fields are returned. type FieldSelector = [ByteString] -- | Sets the number of documents to omit - starting from the first -- document in the resulting dataset - when returning the result of the -- query. type NumToSkip = Int32 -- | This controls how many documents are returned at a time. The cursor -- works by requesting NumToReturn documents, which are then -- immediately all transfered over the network; these are held locally -- until the those NumToReturn are all consumed and then the -- network will be hit again for the next NumToReturn documents. -- -- If the value 0 is given, the database will choose the number -- of documents to return. -- -- Otherwise choosing a good value is very dependant on the document size -- and the way the cursor is being used. type NumToReturn = Int32 -- | A BsonDoc representing restrictions for a query much like the -- where part of an SQL query. type Selector = BsonDoc -- | Options that control the behavior of a query operation. data QueryOpt QO_TailableCursor :: QueryOpt QO_SlaveOK :: QueryOpt QO_OpLogReplay :: QueryOpt QO_NoCursorTimeout :: QueryOpt -- | Options that effect the behavior of a update operation. data UpdateFlag UF_Upsert :: UpdateFlag UF_Multiupdate :: UpdateFlag -- | Return the number of documents in Collection. count :: Connection -> Collection -> IO Int64 -- | Return the number of documents in Collection matching -- Selector countMatching :: Connection -> Collection -> Selector -> IO Int64 -- | Delete documents matching Selector from the given -- Collection. delete :: Connection -> Collection -> Selector -> IO RequestID -- | Insert a single document into Collection. insert :: Connection -> Collection -> BsonDoc -> IO RequestID -- | Insert a list of documents into Collection. insertMany :: Connection -> Collection -> [BsonDoc] -> IO RequestID -- | Open a cursor to find documents in Collection that match -- Selector. See the documentation for each argument's type for -- information about how it effects the query. query :: Connection -> Collection -> [QueryOpt] -> NumToSkip -> NumToReturn -> Selector -> FieldSelector -> IO Cursor -- | An alias for delete. remove :: Connection -> Collection -> Selector -> IO RequestID -- | Update documents with BsonDoc in Collection that match -- Selector. update :: Connection -> Collection -> [UpdateFlag] -> Selector -> BsonDoc -> IO RequestID -- | Open a cursor to find documents. If you need full functionality, see -- query find :: Connection -> Collection -> Selector -> IO Cursor -- | Query, but only return the first result, if any. findOne :: Connection -> Collection -> Selector -> IO (Maybe BsonDoc) -- | Perform a query and return the result as a lazy list. Be sure to -- understand the comments about using the lazy list given for -- allDocs. quickFind :: Connection -> Collection -> Selector -> IO [BsonDoc] -- | Perform a query and return the result as a strict list. quickFind' :: Connection -> Collection -> Selector -> IO [BsonDoc] -- | An Itertaor over the results of a query. Use nextDoc to get -- each successive result document, or allDocs or allDocs' -- to get lazy or strict lists of results. data Cursor -- | Return a lazy list of all (of the rest) of the documents in the -- cursor. This works much like hGetContents--it will lazily read the -- cursor data out of the database as the list is used. The cursor is -- automatically closed when the list has been fully read. -- -- If you manually finish the cursor before consuming off this list you -- won't get all the original documents in the cursor. -- -- If you don't consume to the end of the list, you must manually close -- the cursor or you will leak the cursor, which may also leak on the -- database side. allDocs :: Cursor -> IO [BsonDoc] -- | Returns a strict list of all (of the rest) of the documents in the -- cursor. This means that all of the documents will immediately be read -- out of the database and loaded into memory. allDocs' :: Cursor -> IO [BsonDoc] -- | Manually close a cursor -- usually not needed if you use -- allDocs, allDocs', or nextDoc. finish :: Cursor -> IO () -- | Return one document or Nothing if there are no more. Automatically -- closes the curosr when last document is read nextDoc :: Cursor -> IO (Maybe BsonDoc) instance Show Reply instance Show Hdr instance Show UpdateFlag instance Enum UpdateFlag instance Show QueryOpt instance Eq MongoDBOperationFailure instance Show MongoDBOperationFailure instance Read MongoDBOperationFailure instance Eq MongoDBCollectionInvalid instance Show MongoDBCollectionInvalid instance Read MongoDBCollectionInvalid instance Eq MongoDBInternalError instance Show MongoDBInternalError instance Read MongoDBInternalError instance Show Opcode instance Eq Opcode instance Show ColCreateOpt instance Eq ColCreateOpt instance Exception MongoDBOperationFailure instance Typeable MongoDBOperationFailure instance Exception MongoDBCollectionInvalid instance Typeable MongoDBCollectionInvalid instance Exception MongoDBInternalError instance Typeable MongoDBInternalError