mongoDB-0.9.1: A driver for MongoDB

Database.MongoDB.Internal.Protocol

Contents

Description

Low-level messaging between this client and the MongoDB server, see Mongo Wire Protocol (http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol).

This module is not intended for direct use. Use the high-level interface at Database.MongoDB.Query and Database.MongoDB.Connection instead.

Synopsis

Pipe

type Pipe = Pipeline Message ResponseSource

Thread-safe TCP connection with pipelined requests

send :: Pipe -> [Notice] -> IOE ()Source

Send notices as a contiguous batch to server with no reply. Throw IOError if connection fails.

call :: Pipe -> [Notice] -> Request -> IOE (IOE Reply)Source

Send notices and request as a contiguous batch to server and return reply promise, which will block when invoked until reply arrives. This call and resulting promise will throw IOError if connection fails.

Message

type FullCollection = UStringSource

Database name and collection name with period (.) in between. Eg. "myDb.myCollection"

Notice

data Notice Source

A notice is a message that is sent with no reply

Instances

data UpdateOption Source

Constructors

Upsert

If set, the database will insert the supplied object into the collection if no matching document is found

MultiUpdate

If set, the database will update all matching objects in the collection. Otherwise only updates first matching doc

data DeleteOption Source

Constructors

SingleRemove

If set, the database will remove only the first matching document in the collection. Otherwise all matching documents will be removed

Request

data Request Source

A request is a message that is sent with a Reply returned

Constructors

Query 

Fields

qOptions :: [QueryOption]
 
qFullCollection :: FullCollection
 
qSkip :: Int32

Number of initial matching documents to skip

qBatchSize :: Int32

The number of document to return in each batch response from the server. 0 means use Mongo default. Negative means close cursor after first batch and use absolute value as batch size.

qSelector :: Document

[] = return all documents in collection

qProjector :: Document

[] = return whole document

GetMore 

Instances

data QueryOption Source

Constructors

TailableCursor

Tailable means cursor is not closed when the last data is retrieved. Rather, the cursor marks the final object's position. You can resume using the cursor later, from where it was located, if more data were received. Like any latent cursor, the cursor may become invalid at some point  for example if the final object it references were deleted. Thus, you should be prepared to requery on CursorNotFound exception.

SlaveOK

Allow query of replica slave. Normally these return an error except for namespace local.

NoCursorTimeout 
AwaitData

Use with TailableCursor. If we are at the end of the data, block for a while rather than returning no data. After a timeout period, we do return as normal. | Exhaust -- ^ Stream the data down full blast in multiple more packages, on the assumption that the client will fully read all data queried. Faster when you are pulling a lot of data and know you want to pull it all down. Note: the client is not allowed to not read all the data unless it closes the connection.

Reply

data Reply Source

A reply is a message received in response to a Request

Constructors

Reply 

Instances

data ResponseFlag Source

Constructors

CursorNotFound

Set when getMore is called but the cursor id is not valid at the server. Returned with zero results.

QueryError

Query error. Returned with one document containing an $err field holding the error message.

AwaitCapable

For backward compatability: Set when the server supports the AwaitData query option. if it doesn't, a replica slave client should sleep a little between getMore's

Authentication