Databases Reference
In-Depth Information
Request:
Message Header, Request Payload
MongoDB
Server
Client
Response:
Message Header, Request Payload
FIGURE 13-1
The MongoDB wire protocol allows a number of operations. The allowed operations are as follows:
RESERVED is also an operation, which was formerly used for OP_GET_BY_OID . It's
not listed in the list of opcodes as it's not actively used.
OP_INSERT (code: 2002) — Insert a document. The “create” operation in CRUD jargon.
CRUD, which stands for Create, Read, Update and Delete, are standard data
management operations. Many systems and interfaces that interact with
data facilitate the CRUD operations.
OP_UPDATE (code: 2001) — Update a document. The update operation in CRUD.
OP_QUERY (code: 2004) — Query a collection of documents. The “read” operation in
CRUD.
OP_GET_MORE (code: 2005) — Get more data from a query. Query response can contain a
large number of documents. To enhance performance and avoid sending the entire set of
documents, databases involve the concept of a cursor that allows for incremental fetching
of the records. The OP_GET_MORE operation facilitates fetching additional documents via a
cursor.
OP_REPLY (code: 1) — Reply to a client request. This operation sends responses in reply to
OP_QUERY and OP_GET_MORE operations.
OP_KILL_CURSORS (code: 2007) — Operation to close a cursor.
OP_DELETE (code: 2006) — Delete a document.
OP_MSG (code: 1000) — Generic message command.
Every request and response message has a header. A standard message header has the following
properties:
messageLength — The length of the message in bytes. Paradoxically, the length includes
4 bytes to hold the length value.
Search WWH ::




Custom Search