Skip to content

Commit

Permalink
Expose a common interface between Client and Tx (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
lsdch authored Mar 12, 2024
1 parent ce5193c commit 0be826d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
4 changes: 4 additions & 0 deletions export.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ type (
// ErrorTag is the argument type to Error.HasTag().
ErrorTag = edgedb.ErrorTag

// Executor is a common interface between Client and Tx,
// that can run queries on an EdgeDB database.
Executor = edgedb.Executor

// IsolationLevel documentation can be found here
// https://www.edgedb.com/docs/reference/edgeql/tx_start#parameters
IsolationLevel = edgedb.IsolationLevel
Expand Down
29 changes: 29 additions & 0 deletions internal/client/executor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// This source file is part of the EdgeDB open source project.
//
// Copyright EdgeDB Inc. and the EdgeDB authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package edgedb

import "context"

// Executor is a common interface between *Client and *Tx,
// that can run queries on an EdgeDB database.
type Executor interface {
Execute(context.Context, string, ...any) error
Query(context.Context, string, any, ...any) error
QueryJSON(context.Context, string, *[]byte, ...any) error
QuerySingle(context.Context, string, any, ...any) error
QuerySingleJSON(context.Context, string, any, ...any) error
}
12 changes: 12 additions & 0 deletions rstdocs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ ErrorTag is the argument type to Error.HasTag().
type ErrorTag = edgedb.ErrorTag
*type* Executor
---------------

Executor is a common interface between Client and Tx,
that can run queries on an EdgeDB database.


.. code-block:: go
type Executor = edgedb.Executor
*type* IsolationLevel
---------------------

Expand Down

0 comments on commit 0be826d

Please sign in to comment.