diff options
Diffstat (limited to 'src/mongo.go')
-rw-r--r-- | src/mongo.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo.go b/src/mongo.go index d00abd2..54f9533 100644 --- a/src/mongo.go +++ b/src/mongo.go | |||
@@ -15,6 +15,18 @@ type mongoClient struct { | |||
15 | col *mongo.Collection | 15 | col *mongo.Collection |
16 | } | 16 | } |
17 | 17 | ||
18 | func (mc *mongoClient) init(dbName, colName string) error { | ||
19 | var err error | ||
20 | if err = mc.Connect(dbName, colName); err != nil { | ||
21 | return err | ||
22 | } | ||
23 | if err = mc.Drop(); err != nil { | ||
24 | return err | ||
25 | } | ||
26 | |||
27 | return nil | ||
28 | } | ||
29 | |||
18 | func (mc *mongoClient) Connect(dbName, colName string) error { | 30 | func (mc *mongoClient) Connect(dbName, colName string) error { |
19 | var err error | 31 | var err error |
20 | mc.client, err = mongo.NewClient(options.Client().ApplyURI("mongodb://localhost:27017")) | 32 | mc.client, err = mongo.NewClient(options.Client().ApplyURI("mongodb://localhost:27017")) |