Skip to content

Commit

Permalink
fix(conn): added Connector interface to represents database query and…
Browse files Browse the repository at this point in the history
… command
  • Loading branch information
cnlangzi committed Apr 25, 2024
1 parent a0ce484 commit cf71457
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions conn.go → connector.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package sqle

import "context"
import (
"context"
"database/sql"
)

// Conn represents a database connection. Context and Tx both implement this interface.
type Conn interface {
// Connector represents a database connector that provides methods for executing queries and commands.
// Context and Tx both implement this interface.
type Connector interface {
// Query executes a query that returns multiple rows.
// It takes a query string and optional arguments.
// It returns a pointer to a Rows object and an error, if any.
Expand Down Expand Up @@ -33,4 +37,19 @@ type Conn interface {
// It takes a context, a query string, and optional arguments.
// It returns a pointer to a Row object.
QueryRowContext(ctx context.Context, query string, args ...any) *Row

// Exec executes a query that doesn't return any rows.
// It takes a query string and optional arguments.
// It returns a sql.Result object and an error, if any.
Exec(query string, args ...any) (sql.Result, error)

// ExecContext executes a query that doesn't return any rows using a context.
// It takes a context, a query string, and optional arguments.
// It returns a sql.Result object and an error, if any.
ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

// ExecBuilder executes a query that doesn't return any rows using a Builder object.
// It takes a context and a Builder object.
// It returns a sql.Result object and an error, if any.
ExecBuilder(ctx context.Context, b *Builder) (sql.Result, error)
}

0 comments on commit cf71457

Please sign in to comment.