@@ -31,8 +31,8 @@ type scopable interface {
31
31
scope (bson.M ) bson.M
32
32
}
33
33
34
- var _ scopable = & Base {}
35
- var _ scopable = & Paranoid {}
34
+ var _ scopable = Base {}
35
+ var _ scopable = Paranoid {}
36
36
37
37
type destroyable interface {
38
38
destroy (ctx context.Context , collectionName string ) error
@@ -49,7 +49,7 @@ type Validable interface {
49
49
Validate (ctx context.Context ) * ValidationErrors
50
50
}
51
51
52
- var _ Validable = & Base {}
52
+ var _ Validable = Base {}
53
53
54
54
// Create inser the document in the database, returns an error if document already exists and set CreatedAt timestamp
55
55
func Create (ctx context.Context , collectionName string , doc document ) error {
@@ -236,24 +236,22 @@ func Update(ctx context.Context, collectionName string, update bson.M, doc docum
236
236
}
237
237
238
238
func EnsureParanoidIndices (ctx context.Context , collectionNames ... string ) {
239
- go func () {
240
- log := logger .Get (ctx )
241
-
242
- for _ , collectionName := range collectionNames {
243
- log := logger .Get (ctx ).WithFields (logrus.Fields {
244
- "init" : "setup-indices" ,
245
- "collection" : collectionName ,
246
- })
247
- ctx := logger .ToCtx (ctx , log )
248
- log .Info ("Setup the MongoDB index" )
249
-
250
- c := mongo .Session (log ).Clone ().DB ("" ).C (collectionName )
251
- defer c .Database .Session .Close ()
252
- err := c .EnsureIndexKey ("deleted_at" )
253
- if err != nil {
254
- log .WithError (err ).Error ("fail to setup the deleted_at index" )
255
- return
256
- }
239
+ log := logger .Get (ctx )
240
+
241
+ for _ , collectionName := range collectionNames {
242
+ log = logger .Get (ctx ).WithFields (logrus.Fields {
243
+ "init" : "setup-indices" ,
244
+ "collection" : collectionName ,
245
+ })
246
+ ctx = logger .ToCtx (ctx , log )
247
+ log .Info ("Setup the MongoDB index" )
248
+
249
+ c := mongo .Session (log ).Clone ().DB ("" ).C (collectionName )
250
+ defer c .Database .Session .Close ()
251
+ err := c .EnsureIndexKey ("deleted_at" )
252
+ if err != nil {
253
+ log .WithError (err ).Error ("fail to setup the deleted_at index" )
254
+ continue
257
255
}
258
- }()
256
+ }
259
257
}
0 commit comments