Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
54 lines (42 sloc) 1.17 KB
// Copyright 2009-2011 The gomongo Authors. All rights reserved.
// Use of this source code is governed by the 3-clause BSD License
// that can be found in the LICENSE file.
package mongo
import (
type Database struct {
Conn *Connection
name string
func (self *Database) GetCollection(name string) *Collection {
return &Collection{self, name}
func (self *Database) Drop() os.Error {
cmd, err := Marshal(map[string]int{"dropDatabase": 1})
if err != nil {
return err
_, err = self.Command(cmd)
return err
func (self *Database) Repair(preserveClonedFilesOnFailure, backupOriginalFiles bool) os.Error {
cmd := &_Object{
"repairDatabase": &_Number{1, _Null{}},
"preserveClonedFilesOnFailure": &_Boolean{preserveClonedFilesOnFailure, _Null{}},
"backupOriginalFiles": &_Boolean{backupOriginalFiles, _Null{}},
_, err := self.Command(cmd)
return err
func (self *Database) Command(cmd BSON) (BSON, os.Error) {
coll := self.GetCollection("$cmd")
return coll.FindOne(cmd)
func (self *Database) GetCollectionNames() *vector.StringVector {
return new(vector.StringVector)
Jump to Line
Something went wrong with that request. Please try again.