Two way collection link [Feature/add-on request]

Essentially the way I envision it working is that if you create a collection link within both collections, with some type of common identifier in the JSON attributes, and select collectionB.item2 from collectionA.item1, collectionB.item2 would show that it was linked from collectionA.item1.

This would build a two way relationship, which can be helpful. In my use case, I’m building a documentation site build of modules that have relationships to one another. I can do this currently, but it’s manual and not two-way. So if I make a change in the relationship, I have to make the change across multiple entries.

1 Like


This is how laravel-mongo describes it:

The inverse relation is auto magically available, you don’t need to define this reverse relation.

$user = $book->user;

Just bumping for visibility.

Hi Jason, my two cents here.

Create a ModuleRelationships collection that has two collectionlink fields that both link to the Module collection. Whenever two modules are related, add an item to that collection referencing the two modules (a module can even be related to itself under this scenario).

It does not matter which module goes to which field, it only matters how the relationship will be fetched. To retrieve all the modules related to a given module you can filter the ModuleRelationships collection for all the items that have one collectionlink field that references that particular module. Cockpit’s filter capabilities should support this nicely.

EDIT: In addition to this, if you click the LINKED button in the Edit Entry page while editing a module you can see which entries in the ModuleRelationships collection point to that module.

1 Like