httk.store.mongo.documents

Encoding and decoding of MongoStore record documents.

Exceptions

RecordTooLargeError

A record document exceeds the connected MongoDB BSON limit.

Functions

encode_record(schema, projected, source, record_type, ...)

Encode projected field values into the record's f document.

decode_record(schema, document, resolve_reference)

Decode a MongoDB record document into its concrete storable instance.

preflight_document(document, max_bson_size, record_type)

Raise when document cannot be accepted by MongoDB's BSON limit.

Module Contents

exception httk.store.mongo.documents.RecordTooLargeError[source]

Bases: ValueError

A record document exceeds the connected MongoDB BSON limit.

httk.store.mongo.documents.encode_record(schema, projected, source, record_type, resolve_reference)[source]

Encode projected field values into the record’s f document.

Parameters:
Returns:

The embedded f document.

Return type:

dict[str, Any]

httk.store.mongo.documents.decode_record(schema, document, resolve_reference)[source]

Decode a MongoDB record document into its concrete storable instance.

Parameters:
Returns:

A concrete record instance.

Return type:

Any

httk.store.mongo.documents.preflight_document(document, max_bson_size, record_type)[source]

Raise when document cannot be accepted by MongoDB’s BSON limit.

Parameters:
  • document (collections.abc.Mapping[str, Any]) – Candidate record document.

  • max_bson_size (int) – The server BSON limit read at store construction.

  • record_type (type) – The record class used in the diagnostic.

Returns:

None.

Raises:

RecordTooLargeError – If BSON encoding exceeds the server limit.

Return type:

None