summaryrefslogtreecommitdiffstats
path: root/src/mongo.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo.go')
-rw-r--r--src/mongo.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/mongo.go b/src/mongo.go
index 3a23131..764f877 100644
--- a/src/mongo.go
+++ b/src/mongo.go
@@ -78,6 +78,13 @@ func (mc *mongoClient) Finddoc(filter bson.M) ([]bson.M, error) {
78 return results, err 78 return results, err
79} 79}
80 80
81func (mc *mongoClient) FindOneAndDelete(filter bson.M) (bson.M, error) {
82 res := mc.col.FindOneAndDelete(context.Background(), filter)
83 var result bson.M
84 err := res.Decode(&result)
85 return result, err
86}
87
81func (mc *mongoClient) Drop() error { 88func (mc *mongoClient) Drop() error {
82 return mc.col.Drop(context.Background()) 89 return mc.col.Drop(context.Background())
83} 90}
@@ -94,11 +101,14 @@ func (mc *mongoClient) Disconnect() error {
94 return nil 101 return nil
95} 102}
96 103
97func (mc *mongoClient) GetLock() { 104func (mc *mongoClient) GetLock() bool {
98 for i := 0; i < 20000; { 105 for i := 0; i < 200000; {
99 if !mc.Mutex.TryLock() { 106 if !mc.Mutex.TryLock() {
100 i++ 107 i++
108 } else {
109 return true
101 } 110 }
102 } 111 }
103 fmt.Printf("Die...\n") 112 fmt.Printf("Die...\n")
113 return false
104} 114}