db

package
v0.0.0-...-588f2ff Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2016 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package db provides abstractions that makes it easy to interact with the ql database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*sql.DB

	Queryer
	// contains filtered or unexported fields
}

DB extends sql.DB .

func Open

func Open(dbName, path string) (*DB, error)

Open onens a database connection and returns a *DB instance which is safe for concurrent use.

func (*DB) Kind

func (db *DB) Kind() Kind

Kind retruns what kind of the database the instance is connected to.

type Kind

type Kind int

Kind represent the kind of sql database.

const (
	QL Kind = iota
	Postgres
	MySQL
)

supported databases

type QLQeryer

type QLQeryer struct {
}

QLQeryer implements the Queryer interface for ql database.

func (QLQeryer) CreateSession

func (ql QLQeryer) CreateSession(table string) Query

CreateSession retruns a Query for creating new session.

func (QLQeryer) CreateUser

func (ql QLQeryer) CreateUser(table string) Query

CreateUser creates a new user.

func (QLQeryer) DeleteSession

func (ql QLQeryer) DeleteSession(table string) Query

DeleteSession deletes a session.

func (QLQeryer) FindSessionByKey

func (ql QLQeryer) FindSessionByKey(table string) Query

FindSessionByKey returns a query for finding a session by key.

func (QLQeryer) FindUserBy

func (ql QLQeryer) FindUserBy(table, field string) Query

FindUserBy finds a user by the speicified field.

func (QLQeryer) UpdateSession

func (ql QLQeryer) UpdateSession(table string) Query

UpdateSession updaates session data.

type Query

type Query interface {
	String() string
	IsTx() bool
	Params() []string
}

Query is an interface for SQL query string.

func NewQuery

func NewQuery(q string, tx bool, p ...string) Query

NewQuery retruns a Query interface satisfying object.

type Queryer

type Queryer interface {
	CreateSession(table string) Query
	FindSessionByKey(table string) Query
	UpdateSession(table string) Query
	DeleteSession(table string) Query

	CreateUser(table string) Query
	FindUserBy(table, field string) Query
}

Queryer is an interface for alll Queries executed by the Wuxia application. The methods are few to make sure only important queries that are actually needed are represented.

Jump to

Keyboard shortcuts

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