V8-archive: Add support for M2MM / M2X

Created on 26 Mar 2018  路  6Comments  路  Source: directus/v8-archive

The API should be able to retrieve the nested (related) items based on primary key _and_ mixed collection, meaning it can nest items from multiple different tables

enhancement help wanted

Most helpful comment

This would be a nice feature!!! Would take Directus content contribution to next level, making it not only a CMS, but also a kind of Page builder which allows sortable and modular componentes for pages.

All 6 comments

What do we need to do next to support this? @rijkvanzanten @WellingGuzman

I think we can avoid calling it a UUID... this would use a new Directus specific PK type that concats the collection name and id:

articles-123

To achieve better clarity/visibility, we are now tracking feature requests within the Feature Request project board.

This issue being closed does not mean it's not being considered.

Here are some initial thoughts on M2X relationship.
M2X is kind of M2M so the flow for both of them will be the same.

I will consider 2 collections files and category with media M2X collection as an example for this DOC.

Basic Info

M2X collection will have below fields

  1. id
  2. files_id
  3. collection_key ( Collection Id => It will store the id of category)
  4. collection_type ( Collection Name => category )

Creation of M2X field

  1. App Side Integration
    image

  2. API Side Integration

  • It will be same as an M2M for directus_fields table.
  • But we need a single change in directus_relations table.

    For M2M we had below entries in directus_relations table.

image

  For M2X we need to replace the `collection_one` with any specific keyword. (Either we can use * or any)

image

Note: This values will be passed from `APP` only.

Insert Data

  1. For M2M the payload is
    { "category": [ { "category_id": { "name" : "Lorem Ipsum" } } ] }

  2. We will require the below payload for M2X
    { "media": [ { "collection_key": { "type" : "category", "data" : { "name" : "Lorem Ipsum" } } } ] }

Fetch Data

Implement the needful changes into the current API for getting data of any collection.
Here, when we call the API of files we need to pass the type category to media table to get the category related media.

This looks great so far!

Right now we have been ideating on the Relation Settings design with something like this:

Screen Shot 2019-07-17 at 4 46 09 PM

I defer to @rijkvanzanten on the data payload structure.

This would be a nice feature!!! Would take Directus content contribution to next level, making it not only a CMS, but also a kind of Page builder which allows sortable and modular componentes for pages.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cdwmhcc picture cdwmhcc  路  3Comments

jwkellyiii picture jwkellyiii  路  3Comments

gitlabisbetterthangithub picture gitlabisbetterthangithub  路  3Comments

24js picture 24js  路  3Comments

HashemKhalifa picture HashemKhalifa  路  3Comments