httk.store.backend.mongo.entry_provider

Serve MongoDB-backed records through the neutral entry-provider contract.

Mongo entry identities are the store-managed physical id values carried by the hydrated records. Configured entry families are rendered through their Mongo stored-property plan; configured backing records are also accepted for the schema-derived provider surface used by the SQL provider’s parity tests.

Classes

StoreEntryProvider

Serve configured Mongo entry families or their concrete backings.

Functions

served_specs(schema, prefix)

Return the served (name, field spec, fulltype) triples.

auto_definition(entry_type, schema, prefix)

Build a definition for the JSON-able fields of one backing class.

Module Contents

httk.store.backend.mongo.entry_provider.served_specs(schema, prefix)

Return the served (name, field spec, fulltype) triples.

Parameters:
Returns:

One triple for every non-intrinsic schema field with an OPTIMADE value type. The store-managed id and immutable_id fields are intentionally omitted because serving layers expose them intrinsically.

Return type:

list[tuple[str, httk.store.backend.schema.FieldSpec, str]]

httk.store.backend.mongo.entry_provider.auto_definition(entry_type, schema, prefix)

Build a definition for the JSON-able fields of one backing class.

class httk.store.backend.mongo.entry_provider.StoreEntryProvider(store, classes, *, definitions=None, prefix='_httk_', id_of=None, only_latest=True)

Bases: httk.core.EntryProvider

Serve configured Mongo entry families or their concrete backings.

classes maps public entry-type names to either configured entry-family classes or configured concrete backing classes. Family classes use the family’s MongoStoredPropertyPlan; backing classes use the same schema-derived property contract as the SQL provider. id_of receives (entry_type, sid, hydrated_record) and defaults to the record’s stored id field. only_latest restricts served searchers’ root variables to the latest document of each lineage.

entry_types()

Return definitions for all served entry types.

This provider is an OPTIMADE serving edge, so each definition is returned in its wire form via EntryTypeDefinition.served_form() (idempotent for the already-prefixed supplied and auto-generated definitions).

Returns:

The served entry-type definitions keyed by entry type.

Return type:

collections.abc.Mapping[str, httk.core.EntryTypeDefinition]

property_keys(entry_type)

Return public property names mapped to Mongo response keys.

records(entry_type)

Yield JSON-able records for one served entry type.

relationships(entry_type)

Return relationships grouped by source id, including provenance edges.

Related entries come from stored reference fields, child fields, exposed weak links, and StrongLink provenance edges in both directions: a run’s own edges under their forward wire key, and the derived reverse edges naming the runs pointing at each served target under their reverse wire key. The reverse view is store-scoped; it is lineage-level (latest main run revisions only), matching the SQL provider, under the default only_latest=True (see _reverse_edge_index for the only_latest=False caveat).

Parameters:

entry_type (str) – The served entry type whose relationships are read.

Returns:

Related entries keyed by source entry id.

Raises:

KeyError – If entry_type is not served.

Return type:

collections.abc.Mapping[str, tuple[httk.core.RelatedEntry, Ellipsis]]