db

package
Version: v0.0.0-...-15608e1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

README

db

import "github.com/ardanlabs/kit/db"

Package db abstracts different database systems we can use.

func RegMasterSession

func RegMasterSession(context interface{}, name string, cfg mongo.Config) error

RegMasterSession adds a new master session to the set.

type DB

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

DB is a collection of support for different DB technologies. Currently only MongoDB has been implemented. We want to be able to access the raw database support for the given DB so an interface does not work. Each database is too different.

func NewMGO
func NewMGO(context interface{}, name string) (*DB, error)

NewMGO returns a new DB value for use with MongoDB based on a registered master session.

func (*DB) CloseMGO
func (db *DB) CloseMGO(context interface{})

CloseMGO closes a DB value being used with MongoDB.

func (*DB) CollectionMGO
func (db *DB) CollectionMGO(context interface{}, colName string) (*mgo.Collection, error)

CollectionMGO is used to get a collection value.

func (*DB) CollectionMGOTimeout
func (db *DB) CollectionMGOTimeout(context interface{}, timeout time.Duration, colName string) (*mgo.Collection, error)

CollectionMGOTimeout is used to get a collection value with a timeout.

func (*DB) ExecuteMGO
func (db *DB) ExecuteMGO(context interface{}, colName string, f func(*mgo.Collection) error) error

ExecuteMGO is used to execute MongoDB commands.

func (*DB) ExecuteMGOTimeout
func (db *DB) ExecuteMGOTimeout(context interface{}, timeout time.Duration, colName string, f func(*mgo.Collection) error) error

ExecuteMGOTimeout is used to execute MongoDB commands with a timeout.


Generated by godoc2md

Documentation

Overview

Package db abstracts different database systems we can use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegMasterSession

func RegMasterSession(context interface{}, name string, cfg mongo.Config) error

RegMasterSession adds a new master session to the set.

Types

type DB

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

DB is a collection of support for different DB technologies. Currently only MongoDB has been implemented. We want to be able to access the raw database support for the given DB so an interface does not work. Each database is too different.

func NewMGO

func NewMGO(context interface{}, name string) (*DB, error)

NewMGO returns a new DB value for use with MongoDB based on a registered master session.

func (*DB) CloseMGO

func (db *DB) CloseMGO(context interface{})

CloseMGO closes a DB value being used with MongoDB.

func (*DB) CollectionMGO

func (db *DB) CollectionMGO(context interface{}, colName string) (*mgo.Collection, error)

CollectionMGO is used to get a collection value.

func (*DB) CollectionMGOTimeout

func (db *DB) CollectionMGOTimeout(context interface{}, timeout time.Duration, colName string) (*mgo.Collection, error)

CollectionMGOTimeout is used to get a collection value with a timeout.

func (*DB) ExecuteMGO

func (db *DB) ExecuteMGO(context interface{}, colName string, f func(*mgo.Collection) error) error

ExecuteMGO is used to execute MongoDB commands.

func (*DB) ExecuteMGOTimeout

func (db *DB) ExecuteMGOTimeout(context interface{}, timeout time.Duration, colName string, f func(*mgo.Collection) error) error

ExecuteMGOTimeout is used to execute MongoDB commands with a timeout.

Source Files

Directories

Path Synopsis
Package mongo provides support for using MongoDB.
Package mongo provides support for using MongoDB.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL