1.1. Migrations and Seeders
- Migrations: Define and manage your database schema changes over time. Migrations allow you to version control your database schema and easily apply updates.
- Creating Migrations: Use the command
adonis make:migration migration_name
to create a new migration file. Define schema changes in the generated file and runadonis migration:run
to apply them.
- Creating Migrations: Use the command
- Seeders: Populate your database with sample data using seeders. This is especially useful for development and testing.
- Creating Seeders: Generate seeders with
adonis make:seeder seeder_name
and use thedbSeeder
to populate data.
- Creating Seeders: Generate seeders with
1.2. Query Builder
- Fluent Interface: AdonisJS provides a powerful query builder that supports complex queries and chaining methods for easy and readable database operations.
- Advanced Queries: Use methods like
whereIn
,join
, andgroupBy
for more complex queries.
Leave a Reply