MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / _encode_mapping

Function _encode_mapping

bson/__init__.py:713–718  ·  view source on GitHub ↗

Encode a mapping type.

(name: bytes, value: Any, check_keys: bool, opts: CodecOptions[Any])

Source from the content-addressed store, hash-verified

711
712
713def _encode_mapping(name: bytes, value: Any, check_keys: bool, opts: CodecOptions[Any]) -> bytes:
714 """Encode a mapping type."""
715 if _raw_document_class(value):
716 return b"\x03" + name + cast(bytes, value.raw)
717 data = b"".join([_element_to_bson(key, val, check_keys, opts) for key, val in value.items()])
718 return b"\x03" + name + _PACK_INT(len(data) + 5) + data + b"\x00"
719
720
721def _encode_dbref(name: bytes, value: DBRef, check_keys: bool, opts: CodecOptions[Any]) -> bytes:

Callers

nothing calls this directly

Calls 4

_raw_document_classFunction · 0.90
_element_to_bsonFunction · 0.85
itemsMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected