Skip to main content

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

FieldTypeAttributesDescription
idString@id, @default(cuid())Unique membership ID
userIdStringID of the user in this membership
userUser@relationThe user associated with this membership
worldIdStringID of the world in this membership
worldWorld@relationThe world associated with this membership
roleRole@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"
}
}