ObjectStackObjectStack Protocol

Advanced Types

Detailed specification of complex data types: Lookups, Master-Detail, Formulas, and Summaries.

Beyond standard scalars (string, boolean, number), ObjectQL supports semantic enterprise types.

1. Relationship Types

Relationships form the graph of the data model.

Lookup

A loose link to another object. Comparable to a standard Foreign Key.

  • Behavior: The source field stores the _id of the target record.
  • Deletion: If target is deleted, the field is either set to null or the deletion is blocked (configurable).
manager:
  type: lookup
  reference_to: user
  multiple: false

Master-Detail

A strong parent-child relationship.

  • Ownership: The Child (Detail) cannot exist without the Parent (Master).
  • Cascading Delete: If Master is deleted, all Details are deleted.
  • Sharing: Child implementation inherits permissions from the Master.
project_id:
  type: master_detail
  reference_to: project

2. Computed Types

Computed types are calculated at runtime (read-time) or compile-time (write-time), depending on the backend capability.

Formula

Calculates a value based on other fields in the same record (or parent records).

  • Syntax: Excel-like syntax or JavaScript expression.
  • Storage: Usually virtual (calculated on SELECT), but can be persisted.
total_price:
  type: formula
  formula: "amount * quantity"
  data_type: currency

Summary (Rollup)

Calculates a value based on child records.

  • Operations: COUNT, SUM, MIN, MAX.
  • Context: Only available on the master side of a Master-Detail relationship.
total_tasks:
  type: summary
  summary_object: project_task
  summary_field: id
  summary_type: count

3. Polymorphic Types

Any / Variant

Allows storage of unstructured JSON data.

  • Driver Support: Uses JSONB in Postgres, native JSON in Mongo.

Grid / Table

A "Mini-Table" inside a record. Useful for simple line items (e.g., Expense Lines) without creating a full child object.

On this page