Details
-
Bug
-
Resolution: Fixed
-
Major - P3
-
None
-
None
-
None
-
Fully Compatible
-
ALL
-
Platforms 2017-05-08, Platforms 2017-05-29
Description
An IDL command is a description of a JSON Object. It is the the same as a IDL struct except it understands MongoDB’s command deserialization and serialization rules.
A command either requires required (like collectionStatsCmd), concatenate_with_db (like CmdFindAndModify) or ignored (like serverStatusCmd validation for the first element of a command. The command structs are used for top-level commands because top-level commands have special serialization requirements. Top-level commands require the first field in the command BSON to be the name of the command. If the namespace property is set to required, then the commands require the field to be a string and the value is the full namespace to target. If the namespace property is set to concatenate_with_db, then the commands require the field to be a string and the value is the namespace to target and concatenated with the db name from the MsgHdr on the wire (see Command::parseNsCollectionRequired). For commands that do not need a namespace, they do not check the type or value of the field.
When a command is serialized, fields are serialized in the order listed in the command just like a struct. A special field is serialized as the first element though. This field’s name will be the name of the struct, and its value will be with either a NamespaceString or 1 depending on whether a namespace is required.
When a command is deserialized, the fields are read back in any order. Except the first field is required to match the command schema as described above for the first element.