Skip to main content

mr relation-type create

Create a new RelationType defining a typed link between two Categories. --name, --from-category and --to-category are all required in practice: the two category flags take Category IDs (not names), and the server rejects a missing category outright, and on SQLite rejects one that does not resolve to an existing Category; nothing is persisted either way. It then enforces that relations of this type link groups of those categories. --description is free-form text shown in UIs.

--reverse-name is not a label. It creates a second RelationType of that name with the categories swapped and links the pair, so each is the other's back relation; an existing unlinked reverse type of that name and category pair is adopted rather than duplicated. Passing the same value as --name self-links the type, which requires --from-category and --to-category to be equal. Sends POST /v1/relationType and returns the persisted record.

Usage

mr relation-type create

Examples

Create a basic relation type between two category IDs

mr relation-type create --name "references" --from-category 1 --to-category 2

Create with a description and reverse-name

ID=$(mr relation-type create --name "depends-on" --description "A depends on B" \
--reverse-name "depended-on-by" --from-category 1 --to-category 2 --json | jq -r '.ID')

Flags

FlagTypeDefaultDescription
--namestring``Relation type name (required) (required)
--descriptionstring``Relation type description
--reverse-namestring``Reverse relation name
--from-categoryuint0From category ID
--to-categoryuint0To category ID

Inherited global flags

FlagTypeDefaultDescription
--jsonboolfalseOutput raw JSON
--no-headerboolfalseOmit table headers
--pageint1Page number for list commands (default page size: 50)
--quietboolfalseOnly output IDs
--serverstringhttp://localhost:8181mahresources server URL (env: MAHRESOURCES_URL)

Output

RelationType object with ID, Name, Description, FromCategoryId, ToCategoryId, BackRelationId, CreatedAt/UpdatedAt

Exit Codes

0 on success; 1 on any error

See Also