Skip to Content
ServerModelsUser Model

User Model

Core user profile information.

Schema

{ displayName: string // User's display name primaryEmail?: string // Main email (informational) isAdmin: boolean // Admin privileges createdAt: Date // Auto-generated updatedAt: Date // Auto-generated }

Fields

displayName

User’s display name shown in the UI.

  • Type: String
  • Required: Yes
  • Example: “John Doe”

primaryEmail

Main email address (informational only, not used for auth).

  • Type: String
  • Required: No
  • Lowercase: Yes
  • Trimmed: Yes
  • Example:john@example.com

Authentication uses the Identity model, not this email field.

isAdmin

Whether user has admin privileges.

  • Type: Boolean
  • Default: false

Usage

Create User

const user = new User({ displayName: 'John Doe', primaryEmail: 'john@example.com', isAdmin: false }) await user.save()

Find User

const user = await User.findById(userId) const user = await User.findOne({ primaryEmail: 'john@example.com' })

Update User

user.displayName = 'Jane Doe' await user.save()

Next Steps

Last updated on