Skip to main content
This reference documents all database models used in the application, including their properties, relationships, and methods.

User Model

The User model represents authenticated users in the system. It extends BaseModel and includes authentication capabilities through the AuthFinder mixin. Location: apps/web/app/users/models/user.ts

Properties

id
number
required
Primary key identifier for the user
roleId
number
required
Foreign key reference to the user’s role
fullName
string | null
User’s full name (optional)
email
string
required
User’s email address (unique, used for authentication)
password
string | null
Hashed password using scrypt algorithm (not serialized in API responses)
avatar
Attachment
User avatar image with thumbnail variant support
avatarUrl
string | null
Pre-computed URL for the avatar image
createdAt
DateTime
required
Timestamp when the user was created (auto-generated)
updatedAt
DateTime
Timestamp when the user was last updated (auto-updated)

Relationships

@belongsTo(() => Role)
declare role: BelongsTo<typeof Role>
Each user belongs to one role that defines their permissions and access level.
@hasMany(() => ResetPasswordToken)
declare resetPasswordTokens: HasMany<typeof ResetPasswordToken>
Collection of password reset tokens associated with the user.

Computed Properties

isAdmin
boolean
Returns true if the user has admin role privileges
@computed()
get isAdmin() {
  return this.roleId === Roles.ADMIN
}

Methods

Static method to pre-compute avatar URLs for one or multiple users.
static async preComputeUrls(models: User | User[])
Parameters:
  • models - Single user or array of users to process
Description: Generates thumbnail URLs for user avatars using the attachment manager.
Static property for managing API access tokens.
static accessTokens = DbAccessTokensProvider.forModel(User)
Methods:
  • create(user, abilities?, options?) - Create new access token
  • all(user) - Get all tokens for a user
  • delete(user, tokenId) - Delete a specific token

Authentication

The User model uses the withAuthFinder mixin with the following configuration:
const AuthFinder = withAuthFinder(() => hash.use('scrypt'), {
  uids: ['email'],
  passwordColumnName: 'password',
})
  • Hash Driver: scrypt
  • Unique Identifier: email
  • Password Column: password

Role Model

The Role model defines user roles and their associated permissions. Location: apps/web/app/users/models/role.ts

Properties

id
number
required
Primary key identifier for the role
name
string
required
Role name (e.g., “admin”, “user”)
description
string
required
Human-readable description of the role
createdAt
DateTime
required
Timestamp when the role was created
updatedAt
DateTime
required
Timestamp when the role was last updated

Relationships

@hasMany(() => User)
declare users: HasMany<typeof User>
Collection of users assigned to this role.

ResetPasswordToken Model

The ResetPasswordToken model stores temporary tokens for password reset flows. Location: apps/web/app/users/models/reset_password_token.ts

Properties

id
number
required
Primary key identifier for the token
userId
number
required
Foreign key reference to the user
token
string
required
Unique token string for password reset
createdAt
DateTime
required
Timestamp when the token was created
expiresAt
DateTime
required
Timestamp when the token expires

Relationships

@belongsTo(() => User)
declare user: BelongsTo<typeof User>
The user who requested the password reset.

BaseModel

Abstract base model that provides common timestamp fields for all models. Location: apps/web/app/common/models/base_model.ts

Properties

createdAt
DateTime
required
Timestamp when the record was created (auto-generated)
updatedAt
DateTime | null
Timestamp when the record was last updated (auto-updated)

Usage

Extend BaseModel to automatically include timestamp tracking:
import BaseModel from '#common/models/base_model'

export default class MyModel extends BaseModel {
  // Your model properties
}

Type Definitions

MailBasicTranslation

Interface for email translation content. Location: apps/web/app/common/models/mail_basic_translation.ts
export interface MailBasicTranslation {
  subject: string
  title: string
  subtitle: string
  actionBtn: string
  defaultMessage: string
}
subject
string
required
Email subject line
title
string
required
Main heading in the email
subtitle
string
required
Secondary heading or description
actionBtn
string
required
Text for the call-to-action button
defaultMessage
string
required
Fallback message content

Build docs developers (and LLMs) love