forked from syumai/workers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conn.go
42 lines (34 loc) · 854 Bytes
/
conn.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package d1
import (
"context"
"database/sql/driver"
"errors"
"syscall/js"
)
type Conn struct {
dbObj js.Value
}
var (
_ driver.Conn = (*Conn)(nil)
_ driver.ConnBeginTx = (*Conn)(nil)
_ driver.ConnPrepareContext = (*Conn)(nil)
)
func (c *Conn) Prepare(query string) (driver.Stmt, error) {
stmtObj := c.dbObj.Call("prepare", query)
return &stmt{
stmtObj: stmtObj,
}, nil
}
func (c *Conn) PrepareContext(_ context.Context, query string) (driver.Stmt, error) {
return c.Prepare(query)
}
func (c *Conn) Close() error {
// do nothing
return nil
}
func (c *Conn) Begin() (driver.Tx, error) {
return nil, errors.New("d1: Begin is deprecated and not implemented")
}
func (c *Conn) BeginTx(context.Context, driver.TxOptions) (driver.Tx, error) {
return nil, errors.New("d1: transaction is not currently supported")
}