db

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2018 License: BSD-3-Clause Imports: 7 Imported by: 18

Documentation

Index

Constants

View Source
const (
	DB_NAME    = "itsyouonline-idserver-db"
	DB_SESSION = "itsyouonline/identityserver/dbconnection"
)

Variables

View Source
var (
	//ErrDuplicate indicates the entry is invalid because of a primary key violation
	ErrDuplicate = errors.New("Duplicate")
)

Functions

func Close

func Close()

func Connect

func Connect(url string)

Connect ensures a mongo DB connection is initialized.

func DBMiddleware

func DBMiddleware() func(h http.Handler) http.Handler

func EnsureIndex

func EnsureIndex(collectionName string, index mgo.Index)

EnsureIndex make sure indices are created on certain collection.

func GetCollection

func GetCollection(session *mgo.Session, collectionName string) *mgo.Collection

GetCollection return collection.

func GetDBSession

func GetDBSession(r *http.Request) *mgo.Session

func GetSession

func GetSession() *mgo.Session

GetSession blocking call until session is ready.

func IsDup

func IsDup(err error) bool

IsDup checks if an error means it's a duplicate

func IsNotFound added in v0.9.14

func IsNotFound(err error) bool

IsNotFound checks if an error indicates that a record does not exist

func NewSession

func NewSession() *mgo.Session

func SetDBSession

func SetDBSession(r *http.Request) *mgo.Session

Types

type DBHandler

type DBHandler struct {
	// contains filtered or unexported fields
}

func (*DBHandler) ServeHTTP

func (d *DBHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type DateTime

type DateTime time.Time

DateTime is timestamp in "date-time" format defined in RFC3339

func (DateTime) GetBSON

func (dt DateTime) GetBSON() (interface{}, error)

GetBSON implements bson.Getter since the bson library does not look at underlying types and matches directly the time.Time type

func (*DateTime) MarshalJSON

func (dt *DateTime) MarshalJSON() ([]byte, error)

MarshalJSON override marshalJSON

func (*DateTime) SetBSON

func (dt *DateTime) SetBSON(raw bson.Raw) error

SetBSON implements bson.Setter since the bson library does not look at underlying types and matches directly the time.Time type

func (*DateTime) String

func (dt *DateTime) String() string

String returns it's string representation

func (*DateTime) UnmarshalJSON

func (dt *DateTime) UnmarshalJSON(b []byte) error

UnmarshalJSON override unmarshalJSON

Jump to

Keyboard shortcuts

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