diff options
Diffstat (limited to 'src/mongo/gotools/common/db/command.go')
-rw-r--r-- | src/mongo/gotools/common/db/command.go | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/mongo/gotools/common/db/command.go b/src/mongo/gotools/common/db/command.go index 62fa834309b..d427b3b431b 100644 --- a/src/mongo/gotools/common/db/command.go +++ b/src/mongo/gotools/common/db/command.go @@ -8,9 +8,10 @@ package db import ( "fmt" + "strings" + "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" - "strings" ) // Query flags @@ -131,6 +132,28 @@ func (sp *SessionProvider) IsMongos() (bool, error) { return nodeType == Mongos, nil } +// SupportsCollectionUUID returns true if the connected server identifies +// collections with UUIDs +func (sp *SessionProvider) SupportsCollectionUUID() (bool, error) { + session, err := sp.GetSession() + if err != nil { + return false, err + } + defer session.Close() + + collInfo, err := GetCollectionInfo(session.DB("admin").C("system.version")) + if err != nil { + return false, err + } + + // On FCV 3.6+, admin.system.version will have a UUID + if collInfo != nil && collInfo.GetUUID() != "" { + return true, nil + } + + return false, nil +} + // SupportsRepairCursor takes in an example db and collection name and // returns true if the connected server supports the repairCursor command. // It returns false and the error that occurred if it is not supported. |