httk.core.data_records¶
Stdlib-only records for one declared property value per entry.
Attributes¶
Classes¶
Store one canonical JSON value of one declared property. |
|
Logical entry family for served |
Module Contents¶
- httk.core.data_records.RECORDS_DEFINITION_ID = 'https://schemas.httk.org/defs/v0.1/entrytypes/records'¶
- class httk.core.data_records.DataRecord¶
Store one canonical JSON value of one declared property.
value_jsonis canonical JSON, with sorted object keys, compact separators, and no non-finite numeric values.valuedecodes it on access;value_numberexposes finite numeric values for numeric queries. The human-readable and immutable identifiers and timestamp metadata are excluded from content identity.- Parameters:
definition_id – The property definition IRI for the value.
name – The property name.
value_json – The canonical JSON representation of the value.
id – The human-readable entry id shared by all revisions; minted by the store when None.
immutable_id – The per-revision immutable id; minted by the store when None.
last_modified – The optional timezone-aware metadata timestamp.
- id: Annotated[str | None, IdentitySkip(), Indexed()] = None¶
- immutable_id: Annotated[str | None, IdentitySkip(), Unique()] = None¶
- last_modified: Annotated[datetime.datetime | None, IdentitySkip()] = None¶
- property value: Any¶
Decode and return the stored property value.
- property value_number: float | None¶
The decoded numeric value, stored as a numeric SQL query column.
- classmethod from_value(definition_id, name, value, *, id=None, immutable_id=None, last_modified=None)¶
Encode a value canonically and construct its data record.
- Parameters:
definition_id (str) – The property definition IRI for the value.
name (str) – The property name.
value (Any) – The JSON value to encode.
id (str | None) – The human-readable entry id shared by all revisions; minted by the store when None.
immutable_id (str | None) – The per-revision immutable id; minted by the store when None.
last_modified (datetime.datetime | None) – The optional timezone-aware metadata timestamp.
- Returns:
A data record containing the canonical JSON value.
- Raises:
TypeError – If the value contains an unsupported object.
ValueError – If the value is circular or contains a non-finite number, or if
definition_idornameis invalid orlast_modifiedis not timezone-aware.
- Return type:
Self
- classmethod from_obj(obj)¶
Coerce a mapping or existing record into a
DataRecord.- Parameters:
obj (DataRecord | Mapping[str, Any]) – A data record instance or field mapping.
- Returns:
The existing or newly constructed data record.
- Raises:
TypeError – If
objis neither a data record nor a mapping.ValueError – If the mapping has unknown or invalid fields.
- Return type:
Self
- class httk.core.data_records.DataRecordEntry¶
Logical entry family for served
DataRecordrecords.This family is not itself storable; store a
DataRecorddirectly.- type = 'records'¶
- definition_id = 'https://schemas.httk.org/defs/v0.1/entrytypes/records'¶