func (s *Storage) Quota() *storage.Collection {
	userIndex := mgo.Index{Key: []string{"owner"}, Unique: true}
	c := s.Collection("quota")
	c.EnsureIndex(userIndex)
	return c
}
Quota returns the quota collection from MongoDB.
package db
import (
	"fmt"
	"github.com/tsuru/config"
	"github.com/tsuru/tsuru/db/storage"
	"github.com/tsuru/tsuru/hc"
	"gopkg.in/mgo.v2"
)
const (
	DefaultDatabaseURL  = "127.0.0.1:27017"
	DefaultDatabaseName = "tsuru"
)
type Storage struct {
	*storage.Storage
}
type LogStorage struct {
	*storage.Storage
}
func init() {
	hc.AddChecker("MongoDB", healthCheck)
}
func healthCheck() error {
	conn, err := Conn()
	if err != nil {
		return err
	}
	defer conn.Close()
	return conn.Apps().Database.Session.Ping()
}
func DbConfig(prefix string) (string, string) {
	url, _ := config.GetString(fmt.Sprintf("database:%surl", prefix))
	if url == "" {
		url, _ = config.GetString("database:url")
		if url == "" {
			url = DefaultDatabaseURL
		}
	}
	dbname, _ := config.GetString(fmt.Sprintf("database:%sname", prefix))
	if dbname == "" {
		dbname, _ = config.GetString("database:name")
		if dbname == "" {
			dbname = DefaultDatabaseName
		}
	}
	return url, dbname
}
func Conn() (*Storage, error) {
	var (
		strg Storage
		err  error
	)
	url, dbname := DbConfig("")
	strg.Storage, err = storage.Open(url, dbname)
	return &strg, err
}
func LogConn() (*LogStorage, error) {
	var (
		strg LogStorage
		err  error
	)
	url, dbname := DbConfig("logdb-")
	strg.Storage, err = storage.Open(url, dbname)
	return &strg, err
}
func (s *Storage) Apps() *storage.Collection {
	nameIndex := mgo.Index{Key: []string{"name"}, Unique: true}
	c := s.Collection("apps")
	c.EnsureIndex(nameIndex)
	return c
}
func (s *Storage) Deploys() *storage.Collection {
	deployIndex := mgo.Index{Key: []string{"app", "-timestamp"}}
	c := s.Collection("deploys")
	c.EnsureIndex(deployIndex)
	return c
}
func (s *Storage) Platforms() *storage.Collection {
	return s.Collection("platforms")
}
func (s *Storage) Services() *storage.Collection {
	return s.Collection("services")
}
func (s *Storage) ServiceInstances() *storage.Collection {
	return s.Collection("service_instances")
}
func (s *Storage) Plans() *storage.Collection {
	return s.Collection("plans")
}
func (s *Storage) Pools() *storage.Collection {
	return s.Collection("pool")
}
func (s *Storage) Users() *storage.Collection {
	emailIndex := mgo.Index{Key: []string{"email"}, Unique: true}
	c := s.Collection("users")
	c.EnsureIndex(emailIndex)
	return c
}
func (s *Storage) Tokens() *storage.Collection {
	coll := s.Collection("tokens")
	coll.EnsureIndex(mgo.Index{Key: []string{"token"}})
	return coll
}
func (s *Storage) PasswordTokens() *storage.Collection {
	return s.Collection("password_tokens")
}
func (s *Storage) UserActions() *storage.Collection {
	return s.Collection("user_actions")
}
func (s *Storage) Teams() *storage.Collection {
	return s.Collection("teams")
}