datastore

package
v0.0.0-...-91bf133 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: Apache-2.0 Imports: 3 Imported by: 13

Documentation

Overview

Package datastore implements an interface on top of the mgo mongo client

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bulk

type Bulk interface {
	Upsert(pairs ...interface{})
	RemoveAll(selectors ...interface{})
	Run() (*mgo.BulkResult, error)
}

Bulk is an interface for running Bulk queries on a MongoDB collection

type Collection

type Collection interface {
	Bulk() Bulk
	Pipe(pipeline interface{}) Pipe
	Find(query interface{}) Query
	FindId(id interface{}) Query
	Count() (n int, err error)
	Insert(docs ...interface{}) error
	Remove(selector interface{}) error
	RemoveAll(selector interface{}) (*mgo.ChangeInfo, error)
	UpdateId(id, update interface{}) error
	Upsert(selector, update interface{}) (*mgo.ChangeInfo, error)
	UpsertId(id, update interface{}) (*mgo.ChangeInfo, error)
	DropCollection() error
	EnsureIndex(index mgo.Index) error
}

Collection is an interface for accessing a MongoDB collection

type Config

type Config struct {
	URL      string
	Database string
	Username string
	Password string
	Timeout  time.Duration
}

Config configures the database connection

type Database

type Database interface {
	C(name string) Collection
}

Database is an interface for accessing a MongoDB database

type Pipe

type Pipe interface {
	All(result interface{}) error
	One(result interface{}) error
}

Pipe is an interface for MongoDB aggregation

type Query

type Query interface {
	All(result interface{}) error
	One(result interface{}) error
	Sort(fields ...string) Query
	Select(selector interface{}) Query
}

Query is an interface for querying a MongoDB collection

type Session

type Session interface {
	DB() (Database, func())
	Use(name string) Session
	Fsync(async bool) error
}

Session is an interface for a MongoDB session

func NewSession

func NewSession(conf Config) (Session, error)

NewSession initializes a MongoDB connection to the given host

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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