AdonisJS v6 is coming soon. Get early access to the Alpha release.

August release - 2021

This release introduces AdonisJS drive (a new official package), along with some bug fixes, minor improvements and a breaking change.

Upgrading to the latest versions

The following packages have been updated during the current release.

  • Updated @adonisjs/core from version 5.1.8 -> 5.3.2
  • Updated @adonisjs/ally from version 4.0.2 -> 4.1.1
  • Updated @adonisjs/view from version 6.0.3 -> 6.1.0
  • Updated @adonisjs/repl from version 3.1.2 -> 3.1.6
  • Breaking change   Updated @adonisjs/lucid from version 15.0.1 -> 16.0.0
  • Updated @adonisjs/auth from version 8.0.5 -> 8.0.9

You can upgrade to the latest packages using the npm update command or manually install packages with the @latest tag.

Even though the following packages have received new features/bug fixes. We still recommend updating all of your AdonisJS packages.

npm i @adonisjs/core@latest
npm i @adonisjs/ally@latest
npm i @adonisjs/view@latest
npm i @adonisjs/repl@latest
npm i @adonisjs/lucid@latest
npm i @adonisjs/auth@latest


AdonisJS Drive makes it super simple to manage user uploaded files and save them to cloud storage services like S3, Digital ocean spaces or Google cloud storage.

The best part is, you can still save files on your local file system during development and switch the driver in production to use a cloud storage service (without changing any code).

Using Drive in existing applications

New AdonisJS applications are pre-configured with drive. However, you can also add drive to your existing applications.

Double-check you are using @adonisjs/core >= 5.3.0

  • Create a contracts/drive.ts file and copy-paste the contracts stub inside it. Feel free to uncomment the s3 and gcs blocks (if using them).

  • Create a config/drive.ts file and copy-paste the config stub inside it.

  • Define the DRIVE_DISK environment variable inside the .env file.


Validating environment variables

Optionally, you can also validate the environment variables inside the env.ts file. Just inspect your drive config file and define the validation rules for the environment variables you are using.

Installing gcs and s3 drivers

Make sure to install the gcs and s3 drivers when planning to use these services.

The configure command for both the packages will guide you to make necessary changes to the config and the contracts file.

# For s3 and digital ocean spaces
npm i @adonisjs/drive-s3
node ace configure @adonisjs/drive-s3
# For google cloud storage
npm i @adonisjs/drive-gcs
node ace configure @adonisjs/drive-gcs

That's all you need to do.

Ally Spotify driver

Ally now ships with the Spotify driver as well. It was contributed by romch007 .

To start using the Spotify driver, you must update the contracts/ally.ts file to include Spotify mapping.

declare module '@ioc:Adonis/Addons/Ally' {
// ...other mappings
spotify: {
config: SpotifyDriverConfig
implementation: SpotifyDriverContract

Next, define the configuration inside the config/ally.ts file.

const allyConfig: AllyConfig = {
spotify: {
driver: 'spotify',
clientId: Env.get('SPOTIFY_CLIENT_ID'),
clientSecret: Env.get('SPOTIFY_CLIENT_SECRET'),
callbackUrl: 'http://localhost:3333/spotify/callback',

Lazy loading relationship aggregates

Lucid now allows you to lazy load relationship aggregates using the loadCount and loadAggregate methods.

const post = await Post.firstOrFail()
await post.loadCount('comments')

The loadAggregate method allows you to define a custom aggregate method. For example:

const user = await User.firstOrFail()
user.loadAggregate('exams', (query) => {

Here's the complete documentation for relationship aggregates.

Template env and config globals

The edge templates can now access the env and the config globals to access environment variables and application config.

  • The env global is a reference to the Env.get method.
  • The config global is a reference to the Config.get method.
{{ env('APP_KEY') }}
{{ config('app.key') }}

Breaking change

This is a subtle change in how Lucid models consume the database response of a query. Before this change, we moved all unknown properties (not defined as columns on the model) to the $extras object. For example:

class User extends BaseModel {
public id: number
public name: string
// Make a join query with the user_logins
const users = await User
.innerJoin('user_logins', '', 'user_logins.user_id')

Before this change, we will move the ip_address value to the $extras object on the User model instance, and you can access it as follows.


Now, if you define ip_address as a regular property on the User model, Lucid will set its value and not move ip_address to the $extras object.

class User extends BaseModel {
public id: number
public name: string
public ip_address: string

And you can access the ip_address as a regular property from the User model instance.


You also must enable useDefineForClassFields inside the tsconfig.json file for this feature to work as expected.

"compilerOptions": {
"useDefineForClassFields": true

Upgrade luxon

AdonisJS packages that rely on luxon have been updated to use luxon@2. We recommend you to upgrade the luxon version in your applications as well.

Other improvements

  • improvement: use isDateTime method of luxon over instanceof 5b5e69ef .
  • refactor: allow select method to accept numeric values 478fd7df
  • refactor: do not select all columns for unique and exists validator rules 7beaa798
  • fix: lucid-slugify generate alpha-numeric only slugs 46884629
  • feat: add dashcase to GeneratorFileOptions ac785818

Bug fixes

  • fix: escape single sequence 2f0592b2 .
  • fix: set response status code to 304 when cache is fresh a901f12d
  • fix: make url for route with a wildcard param e02b3b26
  • fix: allow updating primary key localy when using selfAssignPrimaryKey f1c2e5fa
  • fix: normalize seeder custom path for windows 1856ba78
  • fix: Model query builder update method should resolve real column names dacfc5f4
  • fix: convert instances to a string when querying for exists rule 89a495e1
  • fix: increment & decrement methods resolve key names from model columns 027f15e3
  • fix: mark repl file as virtual when compiling ts source 193f4297