forked from btnguyen2k/gocosmos
/
conn.go
38 lines (31 loc) · 919 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
package gocosmos
import (
"database/sql/driver"
"errors"
"time"
)
var (
locGmt, _ = time.LoadLocation("GMT")
)
// Conn is Azure CosmosDB connection handle.
type Conn struct {
restClient *RestClient // Azure CosmosDB REST API client.
defaultDb string // default database used in Cosmos DB operations.
}
// Prepare implements driver.Conn.Prepare.
func (c *Conn) Prepare(query string) (driver.Stmt, error) {
return parseQueryWithDefaultDb(c, c.defaultDb, query)
}
// Close implements driver.Conn.Close.
func (c *Conn) Close() error {
return nil
}
// Begin implements driver.Conn.Begin.
func (c *Conn) Begin() (driver.Tx, error) {
return nil, errors.New("transaction is not supported")
}
// CheckNamedValue implements driver.NamedValueChecker.CheckNamedValue.
func (c *Conn) CheckNamedValue(value *driver.NamedValue) error {
// since CosmosDB is document db, it accepts any value types
return nil
}