-
Notifications
You must be signed in to change notification settings - Fork 3
Database
Neodyme supports multiple database backends. All data access goes through the DatabaseManager abstraction layer, ensuring consistent behavior regardless of the storage engine.
| Type | Status | Config Value | Requirements |
|---|---|---|---|
| JSON | Stable | json |
None (default) |
| MongoDB | Stable | mongodb |
npm install mongodb mongoose |
| SQLite | Planned | sqlite |
npm install better-sqlite3 |
| MySQL | Planned | mysql |
npm install mysql2 |
| PostgreSQL | Planned | postgresql |
npm install pg |
The simplest option. All data is stored in JSON files in the data/ directory.
databaseType=json
databasePath=data/
getJsonSpacing=true # Pretty-print for readabilitydata/
clients.json # User accounts
friends.json # Friend relationships
tickets.json # Support tickets
creator-codes.json # Creator codes and requests
audit-log.json # Audit log entries
reports.json # User reports
- No external dependencies
- Human-readable data files
- Atomic writes with temp files for safety
- File locking to prevent corruption
- Suitable for small to medium servers
Production-ready database with high scalability.
- Install MongoDB on your system or use a cloud provider (MongoDB Atlas)
- Install the Node.js driver:
npm install mongodb mongoose- Configure
server.properties:
databaseType=mongodb
databasePath=mongodb://localhost:27017/neodyme# Local MongoDB:
databasePath=mongodb://localhost:27017/neodyme
# MongoDB with authentication:
databasePath=mongodb://user:password@localhost:27017/neodyme
# MongoDB Atlas (cloud):
databasePath=mongodb+srv://user:password@cluster.mongodb.net/neodymeMongoDB stores data in the following collections:
-
accounts- User accounts and profiles -
friends- Friend relationships -
tickets- Support tickets -
creatorcodes- Creator codes -
creatorcoderequests- Creator code requests -
auditlogs- Audit log entries
- High performance and scalability
- Built-in replication and sharding
- Suitable for large production servers
- Automatic indexing
All database operations go through DatabaseManager, which delegates to the active database implementation:
Service Layer (TicketService, AuditService, etc.)
|
DatabaseManager (abstraction layer)
|
JsonDatabase OR MongoDatabase
| |
JSON files MongoDB
Services never access the database directly. This means switching from JSON to MongoDB only requires changing databaseType in server.properties.
| Entity | Description |
|---|---|
| Accounts | User accounts with credentials, roles, profiles |
| Friends | Friend relationships and requests |
| Tickets | Support tickets with messages |
| Creator Codes | Affiliate codes and requests |
| Audit Logs | Administrative action history |
| Cloud Storage | User and system cloud storage files |
The backup system works with JSON and SQLite databases.
databaseBackup=true # Enable backups
databaseBackupInterval=60 # Backup every 60 minutes
databaseBackupExpiryDays=7 # Delete backups older than 7 days/backup create # Create manual backup
/backup list # List available backups
/backup stats # Backup statistics
/backup restore <name> # Restore a backup (requires confirmation)
/backup delete <name> # Delete a backup (requires confirmation)
/backup cleanup # Force cleanup of expired backupsBackups include all data files in the data/ directory. Backups are stored in data/backups/ with timestamped folder names.
- Run
/backup restore <backup-name> - Confirm with
/confirm restore - Restart the server after restoration
- Install MongoDB and the driver:
npm install mongodb mongoose - Ensure MongoDB is running
- Update
server.properties:
databaseType=mongodb
databasePath=mongodb://localhost:27017/neodyme- Restart the server
- Existing JSON data will need to be imported manually (create accounts through the interface or import scripts)
- Update
server.properties:
databaseType=json
databasePath=data/- Restart the server
- MongoDB data will need to be exported/imported manually
Redis can be used alongside any database for caching.
redisEnabled=false
redisHost=127.0.0.1
redisPort=6379
redisPassword=npm install ioredis- Authentication tokens
- Profile data
- Session information
Redis improves performance by reducing database queries on frequently accessed data.