Installation
Install IlanaORM:Database Drivers
Install only the database driver you need:Why separate? Database drivers are optional dependencies to reduce package size and security surface. Install only what you need for your project.
Setup Your Project
The easiest way to get started is with the automatic setup:- Configuration file (
ilana.config.js) - Database directories (
database/migrations,database/seeds, etc.) - Models directory (
models/) - Sample environment file (
.env)
Configure Your Database
Edit the generatedilana.config.js file:
SQLite is perfect for learning! It creates a simple file-based database that doesn’t require any server setup. You can always switch to MySQL or PostgreSQL later.
Create Your First Model
Let’s create aUser model to represent users in our application:
models/User.js(or.tsif TypeScript detected)database/migrations/xxxx_create_users_table.js
What’s a Model? Think of a model as a JavaScript class that represents a table in your database. If you have a “users” table, you’d have a “User” model to work with user data.What’s a Migration? A migration is like a recipe for creating or modifying database tables. It tells the database what columns to create, what types they should be, etc.
Define Your Model
Open the generatedmodels/User.js file:
Set Up Your Database Table
Edit the migration file indatabase/migrations/:
Run the Migration
Create the table in your database:Start Using Your Model
Create a simple script to test your setup:test.js
What’s Next?
Learn About Models
Understand how models work and their features
Query Your Data
Learn to find and filter your data
Set Up Relationships
Connect different types of data together
Database Management
Learn about migrations, seeds, and factories
