Skip to main content

Basic Configuration

The ilana.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 one
  • connections - Different databases you can connect to
  • migrations - Where your table blueprints are stored
  • seeds - Where your sample data scripts are stored

Database Connections

SQLite (Perfect for Beginners)

SQLite creates a simple file-based database - no server required!
Why SQLite for learning?
  • No installation required
  • No server to manage
  • Easy to reset (just delete the file)
  • Perfect for development and testing

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
Security Note: Never commit .env files with real passwords to version control. Add .env to your .gitignore file.

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
Best Practice: Always use UTC in your database and convert to user’s local timezone in your application. This prevents confusion when users are in different time zones.

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
Run the test:

Common Configuration Issues

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
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
Problem: Environment variables are undefinedSolutions:
  • Install dotenv: npm install dotenv
  • Add require('dotenv').config() to your config file
  • Check your .env file syntax (no spaces around =)

Next Steps

Create Models

Learn how to define your data models

Database Migrations

Set up your database tables