Add DropDatabase
This commit is contained in:
@@ -13,7 +13,6 @@ type Filter struct {
|
||||
}
|
||||
|
||||
func makeFilter(name string, value any) *Filter {
|
||||
log.Printf("FILTER: %#v", value)
|
||||
var op string
|
||||
|
||||
var v string
|
||||
|
||||
18
main.go
18
main.go
@@ -67,8 +67,6 @@ type CollectionDefinition struct {
|
||||
Discriminator *Discriminator
|
||||
}
|
||||
|
||||
// func (cd *CollectionDefinition) GetSchema(name string)
|
||||
|
||||
// MongoClient
|
||||
type MongoClient struct {
|
||||
// Client the actual connected instance of mongo client.
|
||||
@@ -118,6 +116,22 @@ func (c *MongoClient) AddDefinition(data map[string]any) {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *MongoClient) DropDatabase_DANGER(database string) bool {
|
||||
log.Printf("DANGER attempt to drop database: %s", database)
|
||||
|
||||
db := c.Client.Database(database)
|
||||
|
||||
if err := db.Drop(context.Background()); err != nil {
|
||||
log.Printf("Failed to drop database: %v", err)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
log.Printf("Database %s deleted", database)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *MongoClient) GetCollection(database, name string) *mongo.Collection {
|
||||
if c.Debug {
|
||||
log.Printf("Using collection: %s.%s", database, name)
|
||||
|
||||
Reference in New Issue
Block a user