WorldMembership
The WorldMembership model links users to worlds and assigns them a specific role (OWNER, ADMIN, SUB_ADMIN, MEMBER). This model is essential for managing permissions and access within each world.
Fields
| Field | Type | Attributes | Description |
|---|---|---|---|
| id | String | @id, @default(cuid()) | Unique membership ID |
| userId | String | ID of the user in this membership | |
| user | User | @relation | The user associated with this membership |
| worldId | String | ID of the world in this membership | |
| world | World | @relation | The world associated with this membership |
| role | Role | @default(MEMBER) | The user's role in the world (OWNER, ADMIN, SUB_ADMIN, MEMBER) |
Relationships
- WorldMembership belongs to a User (
userId). - WorldMembership belongs to a World (
worldId).
Constraints
- Each user can only have one membership per world:
@@unique([userId, worldId]).
Example Record
{
"id": "membership1",
"userId": "user123",
"worldId": "world123",
"role": "ADMIN",
"user": {
"id": "user123",
"username": "player1"
},
"world": {
"id": "world123",
"name": "Adventure Realm"
}
}