Good practical intro to Directus relationships. The M2M part is especially useful. Do you have a real-world example where it gets tricky?
Directus Basics Part 2 — Understanding Relationships (M2O, O2M, M2M)
2 Comments
@[jmp] Thanks for sharing! One of the first challenges as a new user is setting up a Many to Many (M2M) relationship for the first time — it's easy to overlook enabling "Create Field" under Corresponding Field, in the Relationship section of Advanced Field Creation Mode.
If you forget this step and save anyway, there's no way to go back and fix it later. The relationship only exists on one collection, and it doesn't automatically create the matching relationship on the other side — which can be frustrating if you don't realize what's happening. And even if you catch the mistake and think "I'll just create the M2M on the other collection to match," the two collections still won't recognize each other as related. You'd end up manually managing both sides, which defeats the entire purpose of setting up the relationship in the first place.
The second issue shows up on the front end, when you query relational data. The Directus SDK makes connecting to the backend pretty easy, but you need to be aware of a special collection Directus creates behind the scenes — the junction collection — which bridges the two related collections. You have to query that junction collection first to access data from either side of the relationship. If you're new to Directus and don't know it exists, this can be tricky to debug — though not impossible to work out once you know what to look for.
You'll also need to make sure the junction collection itself has the correct permissions set, or you won't be able to access the relational data at all. These are the kinds of things that trip people up early on — hopefully I'll get to demonstrate them hands-on in an upcoming video.
Please log in to add a comment.
Please log in to comment on this post.
More Posts
- © 2026 Coder Legion
- Feedback / Bug
- Privacy
- About Us
- Contacts
- You Tube
- Tiktok
- Premium Subscription
- Terms of Service
- Early Builders
I am a full stack developer with my go to stack being Tanstack start, Tailwindcss and Shadcn for the front end. Directus , PostgreSQL, and Redis managed on a VPS using Coolify for my back end. I really enjoy this setup, its fun to work with and it gets the job done.
I started coding since 2014 but only really got serious about it in 2018.
I also create logos and git templates as well, to complement my full stack development. I offer consultancy to my clients and those considering adding an online presence to their business or for those considering a startup.
I love to read and research so I'm passionate about sharing what I have learn't along with my experience. i pray that I can be an inspiration or blessing to someone on this platform. Show less
More From wadethomastt
Related Jobs
- Bilingual Store Associate (Spanish)Sherwin-Williams · Full time · Hagerstown, MD
- Part-Time Center AssociateThe UPS Store 5064 · Full time · Hagerstown, MD
- Echocardiographic Technician (Outpatient), Part-time, Day ShiftAdventist Health · Full time · Ireland
Commenters (This Week)
Contribute meaningful comments to climb the leaderboard and earn badges!