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.
- type FullCollection = UString
- type Pipe = Pipeline Response Message
- newPipe :: Handle -> IO Pipe
- send :: Pipe -> [Notice] -> IOE ()
- call :: Pipe -> [Notice] -> Request -> IOE (IOE Reply)
- data Notice
- = Insert { }
- | Update { }
- | Delete { }
- | KillCursors {
- kCursorIds :: [CursorId]
- data InsertOption = KeepGoing
- data UpdateOption
- = Upsert
- | MultiUpdate
- data DeleteOption = SingleRemove
- type CursorId = Int64
- data Request
- data QueryOption
- = TailableCursor
- | SlaveOK
- | NoCursorTimeout
- | AwaitData
- | Partial
- data Reply = Reply {
- rResponseFlags :: [ResponseFlag]
- rCursorId :: CursorId
- rStartingFrom :: Int32
- rDocuments :: [Document]
- data ResponseFlag
- type Username = UString
- type Password = UString
- type Nonce = UString
- pwHash :: Username -> Password -> UString
- pwKey :: Nonce -> Username -> Password -> UString
Documentation
type FullCollection = UStringSource
Database name and collection name with period (.) in between. Eg. "myDb.myCollection"
Pipe
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.
Notice
A notice is a message that is sent with no reply
Insert | |
| |
Update | |
| |
Delete | |
KillCursors | |
|
data InsertOption Source
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
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
SingleRemove | If set, the database will remove only the first matching document in the collection. Otherwise all matching documents will be removed |
Request
A request is a message that is sent with a Reply
expected in return
Query | |
| |
GetMore | |
data QueryOption Source
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 |
Partial | Get partial results from a _mongos_ if some shards are down, instead of throwing an error. |
Reply
A reply is a message received in response to a Request
Reply | |
|
data ResponseFlag Source
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 |