Skip to main content

apply_projection

Function apply_projection 

Source
pub fn apply_projection(
    records: Vec<RowRecord>,
    fields: &Option<FieldSelector>,
    schema: &SchemaConfig,
) -> Result<Vec<RowRecord>, MiniAppError>
Expand description

Apply field projection to a list of RowRecords.

This is the single shared post-materialization, pre-serialization boundary for field projection across the list, get, and alias_run operations (Crux #1: one function, called by all three handlers).

  • None or Some(FieldSelector::All) → returns records unchanged (backward-compatible).
  • Some(FieldSelector::List { fields }) → validates field names against schema (Crux #2), then projects each row’s data object to the listed fields. The row’s id, created_at, and updated_at are always preserved.

§Errors

Returns MiniAppError::Validation (VALIDATION_ERROR) if any field name in FieldSelector::List is not present in the schema’s canonical field definitions.