Documentation ¶
Index ¶
- Variables
- func Bool(b bool) *bool
- func Byte(b byte) *byte
- func Duration(d time.Duration) *time.Duration
- func Float32(f float32) *float32
- func Float64(f float64) *float64
- func Int(i int) *int
- func Int16(i int16) *int16
- func Int32(i int32) *int32
- func Int64(i int64) *int64
- func Int8(i int8) *int8
- func Is(b *bool) bool
- func Rune(r rune) *rune
- func String(s string) *string
- func Time(t time.Time) *time.Time
- func Uint(u uint) *uint
- func Uint16(u uint16) *uint16
- func Uint32(u uint32) *uint32
- func Uint64(u uint64) *uint64
- func Uint8(u uint8) *uint8
- type Collection
- type Database
- type MongoDB
- func (db *MongoDB) C(name string) Collection
- func (db *MongoDB) Connect() (err error)
- func (db *MongoDB) Disconnect() error
- func (db *MongoDB) DropCollection(r Record) error
- func (db *MongoDB) Find(r Record) error
- func (db *MongoDB) GetCollectionName(r Record) string
- func (db *MongoDB) Name() string
- func (db *MongoDB) NewLogger(col, prefix string) (logger io.Writer)
- func (db *MongoDB) Peek(r Record) error
- func (db *MongoDB) Query(r Record) Query
- func (db *MongoDB) Remove(r Record) error
- func (db *MongoDB) Save(r Record) error
- func (db *MongoDB) SetDebug(on bool)
- func (db *MongoDB) SystemInformation() string
- func (db *MongoDB) URL() *url.URL
- func (db *MongoDB) UniqueId() string
- func (db *MongoDB) Version() string
- type MongoDBCollection
- func (col *MongoDBCollection) Drop() error
- func (col *MongoDBCollection) Find(r Record) error
- func (col *MongoDBCollection) Name() string
- func (col *MongoDBCollection) Peek(r Record) (err error)
- func (col *MongoDBCollection) Query(q interface{}) Query
- func (col *MongoDBCollection) Remove(r Record) error
- func (col *MongoDBCollection) Save(r Record) error
- type MongoDBLogger
- type MongoDBQuery
- type NewDatabaseDriver
- type Object
- type Query
- type Record
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNotConnected error = errors.New("Not connected to database")
)
View Source
var (
ErrNotFound = errors.New("record not found")
)
Functions ¶
Types ¶
type Collection ¶
type Database ¶
type Database interface { Name() string URL() *url.URL SystemInformation() string Version() string Connect() error Disconnect() error C(string) Collection GetCollectionName(r Record) string DropCollection(Record) error SetDebug(bool) UniqueId() string Save(Record) error Find(Record) error Peek(Record) error Remove(Record) error Query(Record) Query NewLogger(col, prefix string) io.Writer }
A database connection
func NewDatabase ¶
factory method to instantiate database drivers based on the url scheme
type MongoDB ¶
type MongoDB struct { Url *url.URL Database *mgo.Database Session *mgo.Session SessionInfo *mgo.BuildInfo // contains filtered or unexported fields }
func (*MongoDB) C ¶
func (db *MongoDB) C(name string) Collection
func (*MongoDB) Disconnect ¶
func (*MongoDB) DropCollection ¶
func (*MongoDB) GetCollectionName ¶
func (*MongoDB) SystemInformation ¶
type MongoDBCollection ¶
type MongoDBCollection struct {
*mgo.Collection
}
func (*MongoDBCollection) Drop ¶
func (col *MongoDBCollection) Drop() error
func (*MongoDBCollection) Find ¶
func (col *MongoDBCollection) Find(r Record) error
func (*MongoDBCollection) Name ¶
func (col *MongoDBCollection) Name() string
func (*MongoDBCollection) Peek ¶
func (col *MongoDBCollection) Peek(r Record) (err error)
func (*MongoDBCollection) Query ¶
func (col *MongoDBCollection) Query(q interface{}) Query
func (*MongoDBCollection) Remove ¶
func (col *MongoDBCollection) Remove(r Record) error
func (*MongoDBCollection) Save ¶
func (col *MongoDBCollection) Save(r Record) error
type MongoDBLogger ¶
type MongoDBLogger struct { Col *mgo.Collection Prefix string }
type MongoDBQuery ¶
several methods promoted from mgo.Query implement perfect/db.Query
func (*MongoDBQuery) All ¶
func (q *MongoDBQuery) All(result interface{}) (err error)
TODO: write custom driver for mongodb so that 'result' could be of type []Record
func (*MongoDBQuery) Exclude ¶
func (q *MongoDBQuery) Exclude(fields ...string) Query
func (*MongoDBQuery) One ¶
func (q *MongoDBQuery) One(result Record) (err error)
func (*MongoDBQuery) Select ¶
func (q *MongoDBQuery) Select(fields ...string) Query
type NewDatabaseDriver ¶
All DB drivers must implement a NewDatabaseDriver function They accept a connection url and an optional database name.
type Object ¶
type Object struct {
Id interface{} `bson:"_id,omitempty" json:"-"`
}
An object that can be stored in a database; implements the Record interface
Source Files ¶
Click to show internal directories.
Click to hide internal directories.