UserPreference
Stores personalized settings and preferences for each user's experience in the application. This entity allows users to customize how the application looks, behaves, and communicates with them. Preferences can range from UI themes and layout choices to notification settings, privacy options, and feature toggles. Each preference is stored as a key-value pair, making the system extensible - new preferences can be added without changing the database schema. The entity supports different data types (boolean, string, number, JSON) and can organize preferences into categories like 'appearance', 'notifications', or 'privacy'. Default values ensure new users get a sensible starting configuration, while user-specific values override these defaults. This personalization improves user satisfaction by letting each person tailor the application to their needs and working style.
Properties
| Property | Type | Mode | Description | Required |
|---|---|---|---|---|
| user | User | stored | The user who owns these preferences | Required |
| key | string | stored | Unique identifier for the preference setting Example: | Required |
| value | string | stored | The preference value stored as a string (can be parsed based on type) Example: | Required |
| type | string | enum | Data type of the preference value for proper parsing Values: Example: | Optional |
| category | string | stored | Grouping category for organizing related preferences Example: | Optional |
| label | string | stored | Human-readable name for the preference Example: | Optional |
| description | string | stored | Help text explaining what this preference does Example: | Optional |
| defaultValue | string | stored | System default if user hasn't set a value Example: | Optional |
| possibleValues | string[] | stored | List of allowed values for validation Example: | Optional |
| isPublic | boolean | stored | Whether other users can see this preference (for social features) | Optional |
| isEditable | boolean | stored | Whether the user can change this preference | Optional |
| lastModifiedAt | DateTime | stored | When the user last changed this preference | Optional |
| metadata | object | stored | Additional configuration or validation rules | Optional |
Examples
Example 1
{
"@type": "UserPreference",
"key": "notifications.email.marketing",
"value": "false",
"type": "boolean",
"category": "notifications",
"label": "Marketing Emails",
"description": "Receive promotional emails and newsletters about new features and updates",
"defaultValue": "true",
"possibleValues": [
"true",
"false"
],
"isPublic": false,
"isEditable": true,
"lastModifiedAt": "2024-03-10T14:00:00Z",
"metadata": {
"frequency": "weekly",
"lastOptOut": "2024-03-10T14:00:00Z"
}
}Example 2
{
"@type": "UserPreference",
"key": "dashboard.widgets.layout",
"value": "{\"columns\":3,\"widgets\":[{\"id\":\"stats\",\"position\":1},{\"id\":\"chart\",\"position\":2},{\"id\":\"tasks\",\"position\":3}]}",
"type": "json",
"category": "dashboard",
"label": "Dashboard Layout",
"description": "Customized arrangement of widgets on your dashboard",
"defaultValue": "{\"columns\":2,\"widgets\":[]}",
"isPublic": false,
"isEditable": true,
"lastModifiedAt": "2024-02-28T09:30:00Z",
"metadata": {
"maxWidgets": 10,
"allowedWidgets": [
"stats",
"chart",
"tasks",
"calendar",
"news"
]
}
}