|
@@ -16,7 +16,6 @@ import (
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
"go.mongodb.org/mongo-driver/mongo"
|
|
|
"go.mongodb.org/mongo-driver/mongo/options"
|
|
|
- "go.mongodb.org/mongo-driver/mongo/readpref"
|
|
|
)
|
|
|
|
|
|
func NewMgo(addr, db string, size int) *MongodbSim {
|
|
@@ -773,16 +772,3 @@ func autoUpdateTime(db, coll string, ue *bson.M) {
|
|
|
(*ue)["$set"] = set
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-func (ms *MgoSess) ExampleDatabase_RunCommand() {
|
|
|
- // run an explain command to see the query plan for when a "find" is executed on collection "bar"
|
|
|
- // specify the ReadPreference option to explicitly set the read preference to primary
|
|
|
- findCmd := bson.D{{"find", ms.coll}, {"projectid", "5f6bc002499cb0822d7e3322"}}
|
|
|
- command := bson.D{{"explain", findCmd}}
|
|
|
- opts := options.RunCmd().SetReadPreference(readpref.Primary())
|
|
|
- var result bson.M
|
|
|
- if err := ms.M.C.Database(ms.db).RunCommand(context.TODO(), command, opts).Decode(&result); err != nil {
|
|
|
- log.Fatal(err)
|
|
|
- }
|
|
|
- fmt.Println(result)
|
|
|
-}
|