mongo

package
v0.0.0-...-e2f8df6 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2012 License: MIT Imports: 10 Imported by: 0

README

gosexy/db/mongo

This driver is a wrapper of mgo

Requirements

The bazaar version control system is required by mgo.

If you're using brew and OSX, you can install it like this

$ brew install bzr

On ArchLinux you could use

$ sudo pacman -S bzr

And on Debian based distros

$ sudo aptitude install bzr

Installation

$ go get github.com/xiam/gosexy/db/mongo

Usage

import (
  "github.com/xiam/gosexy/db"
  "github.com/xiam/gosexy/db/mongo"
)

Connecting to a MongoDB database

sess := mongo.Session(db.DataSource{Host: "127.0.0.1"})

err := sess.Open()
defer sess.Close()

Read full documentation and examples on the gosexy/db manual.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Session

func Session(config db.DataSource) db.Database

Returns a new MongoDataSource object.

Types

type MongoDataSource

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

MongoDataSource session.

func (*MongoDataSource) Close

func (m *MongoDataSource) Close() error

Entirely drops the active database.

func (*MongoDataSource) Collection

func (m *MongoDataSource) Collection(name string) db.Collection

Returns a Collection from the currently active database given the name. See Session().

func (*MongoDataSource) Collections

func (m *MongoDataSource) Collections() []string

Returns all the collection names in the active database.

func (*MongoDataSource) Driver

func (m *MongoDataSource) Driver() interface{}

func (*MongoDataSource) Drop

func (m *MongoDataSource) Drop() error

Entirely drops the active database.

func (*MongoDataSource) Open

func (m *MongoDataSource) Open() error

Connects to the previously specified datasource. See Session().

func (*MongoDataSource) Use

func (m *MongoDataSource) Use(database string) error

Switches the current session database to the provided name. See Session().

type MongoDataSourceCollection

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

MongoDataSource collection.

func (*MongoDataSourceCollection) Append

func (c *MongoDataSourceCollection) Append(items ...interface{}) bool

Inserts items into the collection.

func (*MongoDataSourceCollection) BuildQuery

func (c *MongoDataSourceCollection) BuildQuery(terms ...interface{}) *mgo.Query

Returns a mgo.Query that matches the provided terms.

func (*MongoDataSourceCollection) Count

func (c *MongoDataSourceCollection) Count(terms ...interface{}) int

Returns the number of total items matching the provided conditions.

func (*MongoDataSourceCollection) Find

func (c *MongoDataSourceCollection) Find(terms ...interface{}) db.Item

Returns a document that matches all the provided conditions. db.Ordering of the terms doesn't matter but you must take in account that conditions are generally evaluated from left to right (or from top to bottom).

func (*MongoDataSourceCollection) FindAll

func (c *MongoDataSourceCollection) FindAll(terms ...interface{}) []db.Item

Returns all the results that match the provided conditions. See Find().

func (*MongoDataSourceCollection) Remove

func (c *MongoDataSourceCollection) Remove(terms ...interface{}) bool

Removes all the items that match the provided conditions.

func (*MongoDataSourceCollection) Truncate

func (c *MongoDataSourceCollection) Truncate() bool

Deletes the whole collection.

func (*MongoDataSourceCollection) Update

func (c *MongoDataSourceCollection) Update(terms ...interface{}) bool

Updates all the items that match the provided conditions. You can specify the modification type by using db.Set, db.Modify or db.Upsert.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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