Join
A virtual reverse relationship that surfaces documents pointing back at this one.
The join field is a virtual, read-only reverse lookup. It does not store data; instead it surfaces the documents in another collection whose relationship field points back at the current document. Use it to show a post's comments or an author's posts without maintaining the link on both sides.
defineJoinField({
name: 'comments',
label: 'Comments',
collection: 'comments',
on: 'post',
})collection is the collection to pull from, and on names the relationship field over there that points back at this document. In the example, each comment has a post relationship, and the join gathers every comment whose post is the current document. Use limit to cap how many related documents come back.
Because a join is virtual, it stores nothing and is read-only in the admin panel — the link is owned entirely by the relationship field on the other collection. It is the natural partner to a Relationship: one side stores the reference, the other surfaces it in reverse.
Join field actions in the admin
On an existing document, the join field can show two helper actions in the admin:
Create newopens the target collection's new-document page and pre-fills the join'sonrelationship field with the current document id.View allopens the target collection list page with awherefilter that matches the join'sonfield to the current document id.
Both actions are shown by default. You can hide either one with join-field admin config:
defineJoinField({
name: "comments",
label: "Comments",
collection: "comments",
on: "post",
admin: {
showCreateButton: true,
showViewButton: true,
},
})If the current document has not been saved yet, Dyrected cannot build those links, so it shows the usual “save first” message instead.
Generated reference
The contract below is generated from the public @dyrected/core exports by @dyrected/knowledge, so it stays in sync with the package. See Fields for the shared field options every type accepts.
JoinField
A virtual reverse relationship that surfaces documents pointing back at this one via collection and on. Read-only; nothing is stored on this document.
export type JoinField = TypedField<"join", unknown, JoinFieldAdmin>;