-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A driver for MongoDB -- -- This module 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.4 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 BsonDoc :: BsonDoc -> BsonValue BsonArray :: [BsonValue] -> BsonValue BsonUndefined :: BsonValue BsonBinary :: BinarySubType -> ByteString -> BsonValue BsonObjectId :: Integer -> BsonValue BsonBool :: !Bool -> BsonValue BsonDate :: POSIXTime -> BsonValue BsonNull :: BsonValue BsonRegex :: ByteString -> String -> BsonValue BsonJSCode :: ByteString -> BsonValue BsonSymbol :: ByteString -> BsonValue BsonJSCodeWScope :: ByteString -> BsonDoc -> BsonValue BsonInt32 :: Int32 -> BsonValue BsonInt64 :: Int64 -> BsonValue BsonMinKey :: BsonValue BsonMaxKey :: BsonValue type BsonDoc = [(ByteString, BsonValue)] data BinarySubType BSTUNDEFINED1 :: BinarySubType BSTFunction :: BinarySubType BSTByteArray :: BinarySubType BSTUUID :: BinarySubType BSTUNDEFINED2 :: BinarySubType BSTMD5 :: BinarySubType BSTUserDefined :: BinarySubType -- | An empty BsonDoc empty :: BsonDoc -- | Convert a BsonValue into a native Haskell type. fromBson :: (BsonConv a) => BsonValue -> a -- | Convert a native Haskell type into a BsonValue. toBson :: (BsonConv a) => a -> BsonValue -- | Convert a BsonDoc into another form such as a Map or a tuple list with -- String keys. fromBsonDoc :: (BsonDocConv a) => BsonDoc -> a -- | Convert a Map or a tuple list with String keys into a BsonDoc. toBsonDoc :: (BsonDocConv a) => a -> BsonDoc getBsonDoc :: Get BsonDoc putBsonDoc :: BsonDoc -> Put data ObjectIdGen mkObjectIdGen :: IO ObjectIdGen genObjectId :: ObjectIdGen -> IO BsonValue instance Eq BsonUnsupportedConversion instance Show BsonUnsupportedConversion instance Read BsonUnsupportedConversion 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 Show BsonValue instance Eq BsonValue instance Ord BsonValue instance (BsonConv a) => BsonConv (Maybe a) instance BsonConv [BsonDoc] instance BsonConv [ByteString] instance BsonConv [ByteString] instance BsonConv [String] instance BsonConv [POSIXTime] instance BsonConv [Bool] instance BsonConv [Word64] instance BsonConv [Word32] instance BsonConv [Word16] instance BsonConv [Word8] instance BsonConv [Word] instance BsonConv [Integer] instance BsonConv [Int64] instance BsonConv [Int32] instance BsonConv [Int16] instance BsonConv [Int8] instance BsonConv [Int] instance BsonConv [Float] instance BsonConv [Double] instance BsonConv Word64 instance BsonConv Word32 instance BsonConv Word16 instance BsonConv Word8 instance BsonConv Word instance BsonConv Integer instance BsonConv Int64 instance BsonConv Int32 instance BsonConv Int16 instance BsonConv Int8 instance BsonConv Int instance BsonConv Bool instance BsonConv POSIXTime instance BsonConv (Map String BsonValue) instance BsonConv (Map ByteString BsonValue) instance BsonConv [(String, BsonValue)] instance BsonConv BsonDoc instance BsonConv ByteString instance BsonConv String instance BsonConv ByteString instance BsonConv Float instance BsonConv Double instance Exception BsonUnsupportedConversion instance Typeable BsonUnsupportedConversion instance BsonDocConv (Map String BsonValue) instance BsonDocConv (Map ByteString BsonValue) instance BsonDocConv [(String, BsonValue)] instance BsonDocConv [(ByteString, BsonValue)] -- | A driver for MongoDB -- -- This module 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. -- --
-- 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 -> FullCollection -> IO String auth :: Connection -> Database -> Username -> Password -> IO BsonDoc -- | create a new user in the current Database addUser :: Connection -> Database -> Username -> Password -> IO BsonDoc -- | log into the mongodb Database attached to the Connection login :: Connection -> Database -> Username -> Password -> IO BsonDoc logout :: Connection -> Database -> IO () -- | The same as FullCollection but without the Database -- prefix. type Collection = ByteString -- | 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] -- | 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 FullCollection = 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 QOTailableCursor :: QueryOpt QOSlaveOK :: QueryOpt QOOpLogReplay :: QueryOpt QONoCursorTimeout :: QueryOpt -- | Options that effect the behavior of a update operation. data UpdateFlag UFUpsert :: UpdateFlag UFMultiupdate :: UpdateFlag -- | Return the number of documents in FullCollection. count :: Connection -> FullCollection -> IO Integer -- | Return the number of documents in FullCollection matching -- Selector countMatching :: Connection -> FullCollection -> Selector -> IO Integer -- | Delete documents matching Selector from the given -- FullCollection. delete :: Connection -> FullCollection -> Selector -> IO RequestID -- | Insert a single document into FullCollection returning the -- _id field. insert :: Connection -> FullCollection -> BsonDoc -> IO BsonValue -- | Insert a list of documents into FullCollection returing the -- _id field for each one in the same order as they were given. insertMany :: Connection -> FullCollection -> [BsonDoc] -> IO [BsonValue] -- | Open a cursor to find documents in FullCollection that match -- Selector. See the documentation for each argument's type for -- information about how it effects the query. query :: Connection -> FullCollection -> [QueryOpt] -> NumToSkip -> NumToReturn -> Selector -> FieldSelector -> IO Cursor -- | An alias for delete. remove :: Connection -> FullCollection -> Selector -> IO RequestID -- | Update documents with BsonDoc in FullCollection that -- match Selector. update :: Connection -> FullCollection -> [UpdateFlag] -> Selector -> BsonDoc -> IO RequestID -- | Conveniently stores the BsonDoc to the FullCollection if -- there is an _id present in the BsonDoc then it already has a -- place in the DB, so we update it using the _id, otherwise we insert it save :: Connection -> FullCollection -> BsonDoc -> IO BsonValue -- | Open a cursor to find documents. If you need full functionality, see -- query find :: Connection -> FullCollection -> Selector -> IO Cursor -- | Query, but only return the first result, if any. findOne :: Connection -> FullCollection -> 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 -> FullCollection -> Selector -> IO [BsonDoc] -- | Perform a query and return the result as a strict list. quickFind' :: Connection -> FullCollection -> Selector -> IO [BsonDoc] -- | Use this in the place of the query portion of a select type query This -- uses javascript and a scope supplied by a BsonDoc to evaluate -- documents in the database for retrieval. -- -- Example: -- --
-- findOne conn mycoll $ whereClause "this.name == (name1 + name2)"
-- Just (toBsonDoc [("name1", toBson "mar"), ("name2", toBson "tha")])
--
whereClause :: String -> Maybe BsonDoc -> BsonDoc
-- | An Iterator 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 cursor when last document is read
nextDoc :: Cursor -> IO (Maybe BsonDoc)
-- | The field key to index on.
type Key = ByteString
-- | Should this index guarantee uniqueness?
type Unique = Bool
-- | Direction to index.
data Direction
Ascending :: Direction
Descending :: Direction
-- | Create a new index on FullCollection on the list of Key
-- / Direction pairs.
createIndex :: Connection -> FullCollection -> [(Key, Direction)] -> Unique -> IO ByteString
-- | Drop the specified index on the given FullCollection.
dropIndex :: Connection -> FullCollection -> [(Key, Direction)] -> IO ()
-- | Drop all indexes on FullCollection.
dropIndexes :: Connection -> FullCollection -> IO ()
-- | Return a BsonDoc describing the existing indexes on
-- FullCollection.
--
-- With the current server versions (1.2) this will return documents such
-- as:
--
--
-- {"key": {"lastname": -1, "firstname": 1},
-- "name": "lastname_-1_firstname_1",
-- "ns": "mydb.people",
-- "unique": true}
--
--
-- Which is a single key that indexes on lastname (descending)
-- and then firstname (ascending) on the collection
-- people of the database mydb with a uniqueness
-- requirement.
indexInformation :: Connection -> FullCollection -> IO [BsonDoc]
data MapReduceOpt
-- | query filter object
MROptQuery :: BsonDoc -> MapReduceOpt
-- | number of objects to return from collection
MROptLimit :: Int64 -> MapReduceOpt
-- | output-collection name
MROptOut :: ByteString -> MapReduceOpt
-- | If set the generated collection is not treated as temporary, as it
-- will be by defualt. When MROptOut is specified, the collection
-- is automatically made permanent.
MROptKeepTemp :: MapReduceOpt
-- | function to apply to all the results when finished
MROptFinalize :: JSCode -> MapReduceOpt
-- | can pass in variables that can be access from mapreducefinalize
MROptScope :: BsonDoc -> MapReduceOpt
-- | provide statistics on job execution time
MROptVerbose :: MapReduceOpt
-- | Run map/reduce and produce a cursor on the results.
mapReduce :: Connection -> FullCollection -> JSCode -> JSCode -> [MapReduceOpt] -> IO Cursor
-- | Run map/reduce with associated scopes and produce a cursor on the
-- results.
mapReduceWScopes :: Connection -> FullCollection -> JSCode -> BsonDoc -> JSCode -> BsonDoc -> [MapReduceOpt] -> IO Cursor
-- | Issue a map/reduce command and return the results metadata. If all you
-- care about is the actual map/reduce results you might want to use the
-- mapReduce command instead.
--
-- The results meta-document will look something like this:
--
--
-- {"result": "tmp.mr.mapreduce_1268095152_14",
-- "timeMillis": 67,
-- "counts": {"input": 4,
-- "emit": 6,
-- "output": 3},
-- "ok": 1.0}
--
--
-- The results field is the collection name within the same
-- Database that contain the results of the map/reduce.
runMapReduce :: Connection -> FullCollection -> JSCode -> JSCode -> [MapReduceOpt] -> IO BsonDoc
-- | Issue a map/reduce command with associated scopes and return the
-- results metadata. If all you care about is the actual map/reduce
-- results you might want to use the mapReduce command instead.
--
-- See runMapReduce for more information about the form of the
-- result metadata.
runMapReduceWScopes :: Connection -> FullCollection -> JSCode -> BsonDoc -> JSCode -> BsonDoc -> [MapReduceOpt] -> IO BsonDoc
-- | Given a result metadata from a mapReduce command (or
-- mapReduceWScope), issue the find command that will
-- produce the actual map/reduce results.
mapReduceResults :: Connection -> Database -> BsonDoc -> IO Cursor
instance Show Direction
instance Eq Direction
instance Show Reply
instance Show Hdr
instance Show UpdateFlag
instance Enum UpdateFlag
instance Show QueryOpt
instance Eq MongoDBConnectionFailure
instance Show MongoDBConnectionFailure
instance Read MongoDBConnectionFailure
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 Show ConnectOpt
instance Eq ConnectOpt
instance Exception MongoDBConnectionFailure
instance Typeable MongoDBConnectionFailure
instance Exception MongoDBOperationFailure
instance Typeable MongoDBOperationFailure
instance Exception MongoDBCollectionInvalid
instance Typeable MongoDBCollectionInvalid
instance Exception MongoDBInternalError
instance Typeable MongoDBInternalError