inital commit
This commit is contained in:
24
delete.go
Normal file
24
delete.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
)
|
||||
|
||||
func deleteAllRows(ctx context.Context, coll *mongo.Collection) {
|
||||
ctx, span := FollowSpan(ctx, "deleteAllRows")
|
||||
defer span.End()
|
||||
|
||||
result, err := coll.DeleteMany(ctx, bson.D{})
|
||||
if err != nil {
|
||||
log.Fatal(result)
|
||||
}
|
||||
|
||||
fmt.Println("Remove all documents...")
|
||||
fmt.Printf("%d documents removed\n", result.DeletedCount)
|
||||
fmt.Println("=============================")
|
||||
}
|
||||
Reference in New Issue
Block a user