Basic Configuration
Theilana.config.js file is the heart of your IlanaORM setup. Think of it as the control panel for your database connections.
Database Drivers: IlanaORM requires you to install database drivers separately. Install only what you need:
- PostgreSQL:
npm install pg - MySQL:
npm install mysql2 - SQLite:
npm install sqlite3
ilana.config.js
What’s happening here?
default- Which database to use when you don’t specify oneconnections- Different databases you can connect tomigrations- Where your table blueprints are storedseeds- Where your sample data scripts are stored
Database Connections
SQLite (Perfect for Beginners)
SQLite creates a simple file-based database - no server required!MySQL
For production applications or when you need advanced features:PostgreSQL
Great for complex applications with advanced data types:Environment-Based Configuration
Use environment variables to keep sensitive information secure:1. Create Environment Files
2. Load Environment Variables
ilana.config.js
Multiple Database Connections
You can connect to multiple databases simultaneously:Using Different Connections
Timezone Configuration
Timezone handling is crucial for applications with users across different time zones:Environment Variable
Set the timezone in your.env file:
.env
Timezone Examples
Advanced Configuration Options
Connection Pooling
Control how many database connections to maintain:Migration Settings
Customize how migrations work:Debugging
Enable query logging for development:Configuration Examples
Development Setup
Production Setup
Testing Your Configuration
Create a simple test script:test-config.js
Common Configuration Issues
Connection Refused
Connection Refused
Problem: Can’t connect to MySQL/PostgreSQLSolutions:
- Check if the database server is running
- Verify host, port, username, and password
- Ensure the database exists
- Check firewall settings
SQLite File Not Found
SQLite File Not Found
Problem: SQLite database file doesn’t existSolutions:
- Run migrations to create the database:
npx ilana migrate - Check the file path in your configuration
- Ensure the directory exists
Environment Variables Not Loading
Environment Variables Not Loading
Problem: Environment variables are undefinedSolutions:
- Install dotenv:
npm install dotenv - Add
require('dotenv').config()to your config file - Check your
.envfile syntax (no spaces around=)
Next Steps
Create Models
Learn how to define your data models
Database Migrations
Set up your database tables
