Back

Database relationships and Auth Teams

  • 0
  • Web
  • Databases
  • Auth
  • General
  • Self Hosted
D5
13 May, 2024, 15:18

You mean the teams feature?

TL;DR
Developers are discussing the best way to handle database relationships and authentication teams in an app. They consider using foreign keys for associations and discuss the possibility of using the Teams feature for managing permissions. The solution proposed is to utilize the Teams feature for permissions and the database for other functionalities.
D5
13 May, 2024, 15:19

I think that the best way is using the teams feature to manage permissions and the database for everything else

TheStockBroker
13 May, 2024, 15:20

But my permissions are "you can only read and write stuff associated with your team"

TheStockBroker
13 May, 2024, 15:20

Which I don't think is odd per-se, right?

TheStockBroker
13 May, 2024, 15:25

Or am I placing semantics on Team which don't apply to it?

TheStockBroker
13 May, 2024, 15:26

I'd still need a way to associate identity to a resource though, like which users are in the codename "Organization", which is a collection I have in my database

TheStockBroker
13 May, 2024, 15:35

Ok I've take a look at what Teams can do, I am abusing its semantics. So the question is now, how do I associate Users to documents?

D5
13 May, 2024, 15:43

Teams allow you to group permissions so you give them to the entire team instead of a particular or some specific users.

D5
13 May, 2024, 15:43

When you create, you set an array with the permissions: https://appwrite.io/docs/advanced/platform/permissions

TheStockBroker
13 May, 2024, 15:44

Forget permissions for now, lets say there are no premissions in my application

TheStockBroker
13 May, 2024, 15:44

it's unrelated to my question in actuality

D5
13 May, 2024, 15:44

Well, if there are no permissions, no one will be able to access the docs.

D5
13 May, 2024, 15:45

Unless you grant permissions for everyone

TheStockBroker
13 May, 2024, 15:45

then permissions are fully lax, everyone can do anything including guests

TheStockBroker
13 May, 2024, 15:45

like I said, it's a totally unrelated conversation

D5
13 May, 2024, 15:45

Okay, so I think I didn't understand it well 😅

TheStockBroker
13 May, 2024, 15:46

I want the moral equivalent of doing GET /things?organization=123, and more importantly I want the moral equivalent of GET /organizations?userId=123

TheStockBroker
13 May, 2024, 15:47

not literal equivalent, I'll be using the SDK, I need to have some sort of abstraction that allows me to group users into organizations

D5
13 May, 2024, 15:47

So basically you mean grouping documents?

TheStockBroker
13 May, 2024, 15:47

yes

D5
13 May, 2024, 15:48

I think best way could be having a collection with all the organisations and then in the grouped docs setting a foreign key (a string) with the document ID that contains the org ID

D5
13 May, 2024, 15:48

An alternative are relationships, but you will not be able to query properly, so that's why I suggest using foreign keys for now

TheStockBroker
13 May, 2024, 15:49

in a not-appwrite app I'd have Organization, Member and User. Organization has many Members and a User can have many Memberships. But in this case I can't associate the User with a Membership

TheStockBroker
13 May, 2024, 15:50

so just using a String attribute and wingging it?

TheStockBroker
13 May, 2024, 15:51

could you elaborate on this? Relationships are not the blessed way to represent relationships?

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