mongoDB-2.0.9: Driver (client) for MongoDB, a free, scalable, fast, document DBMS

Safe HaskellNone
LanguageHaskell2010

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

Documentation

type FullCollection = Text Source

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

Pipe

type Pipe = Pipeline Response Message Source

Thread-safe TCP connection with pipelined requests

newPipe :: Handle -> IO Pipe Source

Create pipe over handle

newPipeWith :: Connection -> IO Pipe Source

Create pipe over connection

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

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

call :: Pipe -> [Notice] -> Request -> IO (IO 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.

Notice

data InsertOption Source

Constructors

KeepGoing

If set, the database will not stop processing a bulk insert if one fails (eg due to duplicate IDs). This makes bulk insert behave similarly to a series of single inserts, except lastError will be set if any insert fails, not just the last one. (new in 1.9.1)

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 expected in return

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 

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

The server normally times out idle cursors after 10 minutes to prevent a memory leak in case a client forgets to close a cursor. Set this option to allow a cursor to live forever until it is closed.

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. Exhaust commented out because not compatible with current Pipeline implementation

Partial

Get partial results from a _mongos_ if some shards are down, instead of throwing an error.

Reply

data Reply Source

A reply is a message received in response to a Request

Constructors

Reply 

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