Get relationship with sum()

I know that I can get additional column with select() when I use sum() function. But, Can I get relationships too?

Route.js Model

class Route extends Model {

    lines () {
        return this.hasMany('App/Models/RouteLine')


RouteLine.js Model 

class RouteLine extends Model {
    route () {
        return this.belongsTo('App/Models/Route')

This is my query.

const routes = await RouteLine
            .select('id', 'checkpoint_id')
            .whereHas('route', (builder) => {
                build.whereBetween('day', [dateStart, dateEnd])
            .sum('quant as quant')

I think Relationships, starting from the Querying Data section is what you need.

I updated the post. I think that my models are correctly defined.

I only want to translate this sql sentence to adonis lucid query without use DB.raw:

const routes = await Database
        .raw('select route_lines.* ,, sum(quant) as suma from route_lines, routes ' +
            'where = route_lines.route_id ' +
            'and between ? and ? group by checkpoint_id', [dateStart, dateEnd]);