Lucid 8.5 - 9.0

Table of contents

The release notes contains an aggregated list of chances made between @adonisjs/[email protected] and @adonisjs/[email protected]. You can also check individual releases on Github.

Upgrade using the following command

npm
npm i @adonisjs/[email protected]
yarn
yarn add @adonisjs/[email protected]

Changes

  • addition: Accept raw and sub queries in orderBy method. f1a4335c

  • addition: Accept raw queries in having method. 5d73de34

  • addition: Add whereColumn method. It allows writing a where clause that uses column names on the both sides e19bcf05.

    Database.query().whereColumn('users.id', '=', 'user_logins.user_id')
    

    The following variations are also added.

    • whereColumn
    • orWhereColumn
    • andWhereColumn
    • whereNotColumn
    • orWhereNotColumn
    • andWhereNotColumn
  • addition: Add support for conditional queries using if, unless and match methods. 17a94205

    if
    Database
      .query()
      .if(auth.user, (query) => query.where('user_id', auth.user.id))
    
    unless
    Database
      .query()
      .unless(auth.user, (query) => query.where('is_public', true))
    
    match
    Database
      .query()
      .match(
        [
          auth.user, (query) => query.where('user_id', auth.user.id)
        ],
        [
          !auth.user, (query) => query.where('is_public', true)
        ],
      )
    
  • addition: Introduce selfAssignPrimarykey property on models to allow assigning primary key locally. This is useful when using uuid as the primary key and not using database to generate one. 7d313122

    class User extends BaseModel {
      public static selfAssignPrimarykey = true
    
      @column({ isPrimary: true })
      public id: string
    }
    
    const user = new User()
    user.id = uuid.v4()
    await user.save()
    
  • improvement: Improve pretty print output for SQL queries debugging and migrations dry run. 6ac54a2d

On this page

Table of contents