Skip to main content
Understanding the character data structure is essential for working with character data in Mythic Framework.

Character Object

The complete character object structure stored in MongoDB:

Required Fields

These fields are required when creating a character:
string
required
First nameValidation:
  • 2-20 characters
  • Letters only (may include spaces, hyphens, apostrophes)
Example: "John", "Mary-Jane", "O'Brien"
string
required
Last nameValidation:
  • 2-30 characters
  • Letters only (may include spaces, hyphens, apostrophes)
Example: "Doe", "Van Der Linde", "O'Sullivan"
string
required
Date of birth in YYYY-MM-DD formatValidation:
  • Must be at least 18 years old
  • Format: YYYY-MM-DD
Example: "1990-01-15", "1985-12-31"
number
required
Gender (numeric value)Values:
  • 0 = Male
  • 1 = Female

Auto-Generated Fields

These fields are automatically set by the system:
number
State ID - unique character identifierAuto-incremented starting from 1
number
Account ID of the player who owns this characterAutomatically set from the player’s AccountID
number
Phone number - unique 10-digit numberAuto-generated when character is created
number
Unix timestamp of character creationSet automatically to os.time() on creation
number
Unix timestamp of last updateUpdated automatically on every save

Default Values

Fields with default values if not specified:

Metadata Structure

The metadata field is a flexible object for storing additional character data:

Appearance

Licenses

Statistics

Reputation

Needs/Status

Achievements

Custom Data

You can store any custom data in metadata:

Working with Character Data

Accessing Fields

Updating Fields

Adding to Metadata


Database Queries

Find by Name

Find by User (Account ID)

Find by Job

Find Characters with Most Cash

Bank balances are stored in the bank_accounts collection, not on the character document. Query that collection separately to find bank balance data.

Validation

Name Validation

DOB Validation

Gender Validation


Example: Complete Character Query


Best Practices

✅ Good:
❌ Bad:

Next Steps

Characters - Exports

Character management methods

Characters - Events

Character lifecycle events

Database API

Database operations

Inventory Data Structure

Inventory and item data
Metadata Flexibility: The metadata field is perfect for storing custom data without modifying the core schema. Use it for resource-specific data, stats, settings, and any dynamic information.