Back

[SOLVED] How to create a relationship between Auth and my collection?

  • 1
  • Databases
  • Accounts
  • Users
  • Web
ThisIsStep2
17 Nov, 2023, 09:24

Hey all, i'm currently trying AppWrite out,
https://appwrite.io/docs/tutorials/react/step-6 As I'm flowing the docs and tutorials, i still didn't find how to create a relationship between userId and the Ideas. I understand to create the field userId, and supply it. but it's without a relationship in the DB, or is it?! Also on the example , it fetches all of the ideas and not the ideas of the current user.

TL;DR
The user is asking how to create a relationship between Auth and their collection in AppWrite. There is currently no option for direct relationship between Auth and a collection. The suggested workaround is to create a separate collection for all users and store the necessary data there. Then, create a relationship between this user collection and the desired collection. They also mention that document security can be activated to assign permission to the owner of the information, eliminating the need for data filtering. To filter requests, they can use the Query class. The user also mentions that they followed the docs and tutorials but didn't find how to create the relationship between userId and Ideas, and
Guille
17 Nov, 2023, 12:12

Currently there is not option to make a relationship between auth (users) and collection.

The approach will be create a collection with all your users, and store all the data you want there, and then in a second collection make a relationship with the "user" collection.

If you activate the document security and assign permission to the owner of the information, you won't need to filter the data, as only will have permission to get the document owned.

To filter a request you can use the Query class, you can check more information here: https://appwrite.io/docs/products/databases/queries

ThisIsStep2
18 Nov, 2023, 19:04

Thanks!

i'm glad that the solution you offered, was the work around i implemented

Guille
20 Nov, 2023, 00:31

[SOLVED] How to create a relationship between Auth and my collection?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more