Skip to content
service.go 699 B
Newer Older
Lo^2's avatar
Lo^2 committed
package db

import (
	"code.electrolab.fr/it/vote.electrolab.fr/service"
	"context"
	"database/sql"
)

type dataCommands interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (Result, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...interface{}) Row
}

type Service interface {
	service.Service
	dataCommands
	Begin() (Tx, error)
}

type Tx interface {
	dataCommands
	Commit() error
	Rollback() error
}

type Result interface {
	sql.Result
}

type Row interface {
	Scan(dest ...interface{}) error
}

type Rows interface {
	Row
	Close() error
	Err() error
	Next() bool
}