n1ql

package
v0.0.0-...-2d3ecc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2023 License: Apache-2.0 Imports: 20 Imported by: 2

README

The tests in this package assume that Couchbase is installed and running on the local machine, with the
query service available at the standard 8093 port. 

The beer-sample sample bucket should be present, with a primary index built.
The default bucket should also be available, with a primary index built.

Documentation

Index

Constants

View Source
const (
	TX_NONE = iota
	TX_START
	TX_COMMIT
	TX_ROLLBACK
)

Variables

View Source
var (
	ErrNotSupported   = fmt.Errorf("N1QL: Not supported")
	ErrNotImplemented = fmt.Errorf("N1QL: Not implemented")
	ErrUnknownCommand = fmt.Errorf("N1QL: Unknown Command")
	ErrInternalError  = fmt.Errorf("N1QL: Internal Error")
)

Common error codes

View Source
var (
	N1QL_SERVICE_ENDPOINT  = "/query/service"
	N1QL_DEFAULT_HOST      = "127.0.0.1"
	N1QL_DEFAULT_PORT      = 8093
	N1QL_POOL_SIZE         = 2 ^ 10 // 1 MB
	N1QL_DEFAULT_STATEMENT = "SELECT RAW 1;"
	LOCALHOST              = N1QL_DEFAULT_HOST
)

defaults

View Source
var HTTPClient = &http.Client{Transport: HTTPTransport}
View Source
var MaxIdleConnsPerHost = 10

HTTPClient to use for REST and view operations.

View Source
var (
	N1QL_PASSTHROUGH_MODE = false
)
View Source
var QueryParams map[string]string

Rest API query parameters

View Source
var TxTimeout string

Functions

func HostNameandPort

func HostNameandPort(node string) (host, port string, ipv6 bool, err error)

Return hostname and port for IPv4 and IPv6

func IsIPv6

func IsIPv6(str string) (bool, error)

func Open

func Open(dataSourceName string) (godbc.DB, error)

func OpenN1QLConnection

func OpenN1QLConnection(name string, userAgent string) (*n1qlConn, error)

func SetCBUserAgentHeader

func SetCBUserAgentHeader(v string)

func SetCaFile

func SetCaFile(cacert string)

func SetCertFile

func SetCertFile(cert string)

func SetIsAnalytics

func SetIsAnalytics(val bool)

func SetKeyFile

func SetKeyFile(key string)

func SetNetworkType

func SetNetworkType(networkType string)

func SetPassthroughMode

func SetPassthroughMode(val bool)

func SetPrivateKeyPassphrase

func SetPrivateKeyPassphrase(passphrase []byte)

func SetQueryParams

func SetQueryParams(key string, value string) error

func SetSkipVerify

func SetSkipVerify(skip bool)

func SetTxTimeout

func SetTxTimeout(value string)

func SetUsernamePassword

func SetUsernamePassword(u, p string)

func UnsetQueryParams

func UnsetQueryParams(key string) error

Types

type N1qlDB

type N1qlDB interface {
	godbc.DB
	PrepareExtended(query string) (N1qlStmt, error)

	// Run the query with the given parameters.
	// Returns the raw streaming input from the body of the RESTful request
	// to the database. The returned error contains a short description
	// of what went wrong with the query.
	//
	// Note that under some conditions, where the request was actually sent to the
	// server, both the stream and an error are returned.
	QueryRaw(query string, args ...interface{}) (io.ReadCloser, error)

	// Execute the statement with the given parameters.
	// Returns the raw streaming input from the body of the RESTful request
	// to the database. The returned error contains a short description
	// of what went wrong with the query.
	//
	// Note that under some conditions, where the request was actually sent to the
	// server, both the stream and an error are returned.
	ExecRaw(query string, args ...interface{}) (io.ReadCloser, error)
}

func OpenExtended

func OpenExtended(dataSourceName string, userAgent string) (N1qlDB, error)

type N1qlStmt

type N1qlStmt interface {
	godbc.Stmt
	QueryRaw(args ...interface{}) (io.ReadCloser, error)
	ExecRaw(args ...interface{}) (io.ReadCloser, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL