// LastTx retrieves a last record with the specified query condition and limit 1 from the database.
LastTx retrieves a last record with the specified query condition and limit 1 from the database.
// LastTx retrieves a last record with the specified query condition and limit 1 from the database .
func (r MigrationRepository) LastTx(ctx context.Context, t migration.Transaction, query *migration.QueryCondition) (*migration.Log, error) {
	var where string
	tx, ok := t.(*sqlx.Tx)
	if !ok {
		return nil, errors.New("can not assert param t migration.Transaction to *sqlx.Tx")
	}
	params := []interface{}{}
	if query != nil && query.Where != nil {
		where = " WHERE status = $1 "
		params = append(params, query.Where.Status)
	}
	entity := &migration.Log{}
	err := tx.GetContext(ctx, entity, "SELECT * FROM " + migration.TableName + where + " ORDER BY id DESC LIMIT 1", params...)
	if err != nil {
		if err == sql.ErrNoRows {
			return nil, apperror.ErrNotFound
		}
	}
	return entity, nil
}
func ( r MigrationRepository ) LastTx ( ctx context . Context , t migration . Transaction , query * migration . QueryCondition ) ( * migration . Log , error ) { var where string tx , ok := t . ( * sqlx . Tx ) if ! ok { return nil , errors . New ( " " ) } params := [ ] interface { } { } if query != nil && query . Where != nil { where = " " params = append ( params , query . Where . Status ) } entity := & migration . Log { } err := tx . GetContext ( ctx , entity , " " + migration . TableName + where + " " , params ... ) if err != nil { if err == sql . ErrNoRows { return nil , apperror . ErrNotFound } } return entity , nil }
LastTx retrieves a last record with the specified query condition and limit 1 from the database.
LastTx retrieves a last record with the specified query condition and limit 1 from the database .