Skip to content

How do I set up a relationship between two models?

Updated 20 August 2026·1 views

Foreign keys

Column-level, on the column itself: \\\json { "name": "project_id", "type": "string", "foreign_key": { "references": "nxf_system_projects(project_id)" }, "hidden": true } \\\ Table-level, in the model''s constraints array — useful for composite keys: \\\json { "constraints": [ { "type": "foreign_key", "fields": ["created_by"], "references": { "table": "nxf_saas_users", "field": "user_id" } } ] } \\\ The public API returns foreign key columns as their raw stored value — it does not expand/populate the related record inline. Fetch the related record with a second request if needed.

Was this article helpful?