5
5
package mongoapi
6
6
7
7
import (
8
+ "context"
8
9
"time"
9
10
10
11
"go.mongodb.org/mongo-driver/bson"
11
12
"go.mongodb.org/mongo-driver/bson/primitive"
13
+ "go.mongodb.org/mongo-driver/mongo"
12
14
)
13
15
14
16
type DBInterface interface {
@@ -19,14 +21,18 @@ type DBInterface interface {
19
21
RestfulAPIPutOneNotUpdate (collName string , filter bson.M , putData map [string ]interface {}) (bool , error )
20
22
RestfulAPIPutMany (collName string , filterArray []primitive.M , putDataArray []map [string ]interface {}) error
21
23
RestfulAPIDeleteOne (collName string , filter bson.M ) error
24
+ RestfulAPIDeleteOneWithContext (collName string , filter bson.M , context context.Context ) error
22
25
RestfulAPIDeleteMany (collName string , filter bson.M ) error
23
26
RestfulAPIMergePatch (collName string , filter bson.M , patchData map [string ]interface {}) error
24
27
RestfulAPIJSONPatch (collName string , filter bson.M , patchJSON []byte ) error
28
+ RestfulAPIJSONPatchWithContext (collName string , filter bson.M , patchJSON []byte , context context.Context ) error
25
29
RestfulAPIJSONPatchExtend (collName string , filter bson.M , patchJSON []byte , dataName string ) error
26
30
RestfulAPIPost (collName string , filter bson.M , postData map [string ]interface {}) (bool , error )
27
31
RestfulAPIPostMany (collName string , filter bson.M , postDataArray []interface {}) error
28
32
GetUniqueIdentity (idName string ) int32
29
33
CreateIndex (collName string , keyField string ) (bool , error )
34
+ StartSession () (mongo.Session , error )
35
+ SupportsTransactions () (bool , error )
30
36
}
31
37
32
38
var CommonDBClient DBInterface
@@ -93,6 +99,10 @@ func (db *MongoDBClient) RestfulAPIDeleteOne(collName string, filter bson.M) err
93
99
return db .MongoClient .RestfulAPIDeleteOne (collName , filter )
94
100
}
95
101
102
+ func (db * MongoDBClient ) RestfulAPIDeleteOneWithContext (collName string , filter bson.M , context context.Context ) error {
103
+ return db .MongoClient .RestfulAPIDeleteOneWithContext (collName , filter , context )
104
+ }
105
+
96
106
func (db * MongoDBClient ) RestfulAPIDeleteMany (collName string , filter bson.M ) error {
97
107
return db .MongoClient .RestfulAPIDeleteMany (collName , filter )
98
108
}
@@ -105,6 +115,10 @@ func (db *MongoDBClient) RestfulAPIJSONPatch(collName string, filter bson.M, pat
105
115
return db .MongoClient .RestfulAPIJSONPatch (collName , filter , patchJSON )
106
116
}
107
117
118
+ func (db * MongoDBClient ) RestfulAPIJSONPatchWithContext (collName string , filter bson.M , patchJSON []byte , context context.Context ) error {
119
+ return db .MongoClient .RestfulAPIJSONPatchWithContext (collName , filter , patchJSON , context )
120
+ }
121
+
108
122
func (db * MongoDBClient ) RestfulAPIJSONPatchExtend (collName string , filter bson.M , patchJSON []byte , dataName string ) error {
109
123
return db .MongoClient .RestfulAPIJSONPatchExtend (collName , filter , patchJSON , dataName )
110
124
}
@@ -124,3 +138,11 @@ func (db *MongoDBClient) GetUniqueIdentity(idName string) int32 {
124
138
func (db * MongoDBClient ) CreateIndex (collName string , keyField string ) (bool , error ) {
125
139
return db .MongoClient .CreateIndex (collName , keyField )
126
140
}
141
+
142
+ func (db * MongoDBClient ) StartSession () (mongo.Session , error ) {
143
+ return db .MongoClient .StartSession ()
144
+ }
145
+
146
+ func (db * MongoDBClient ) SupportsTransactions () (bool , error ) {
147
+ return db .MongoClient .SupportsTransactions ()
148
+ }
0 commit comments