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_nameto create a new migration file. Define schema changes in the generated file and runadonis migration:runto 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_nameand use thedbSeederto 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, andgroupByfor more complex queries.
Leave a Reply