package queries

import (
	"github.com/fiskerinc/cloud-services/pkg/common"
	"github.com/pkg/errors"
)

type DriverEmailsInterface interface {
	SelectByVINs(vins []string) ([]common.DriverEmail, error)
}

type DriverEmails struct {
	QueryBase
}

func (d *DriverEmails) SelectByVINs(vins []string) ([]common.DriverEmail, error) {
	driverEmails := []common.DriverEmail{}
	query := d.GetDBConn().Model(&driverEmails)

	err := query.WhereIn("vin IN (?)", vins).Select()

	return driverEmails, errors.WithStack(err)
}
