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)
"John", "Mary-Jane", "O'Brien"string
required
Last nameValidation:
- 2-30 characters
- Letters only (may include spaces, hyphens, apostrophes)
"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
"1990-01-15", "1985-12-31"number
required
Gender (numeric value)Values:
0= Male1= 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 creationnumber
Unix timestamp of last updateUpdated automatically on every save
Default Values
Fields with default values if not specified:Metadata Structure
Themetadata 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
Use Metadata for Flexible Data
Use Metadata for Flexible Data
✅ Good:❌ Bad:
Validate Before Updates
Validate Before Updates
Index Commonly Queried Fields
Index Commonly Queried Fields
Next Steps
Characters - Exports
Character management methods
Characters - Events
Character lifecycle events
Database API
Database operations
Inventory Data Structure
Inventory and item data