Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-3475

Update CreateCollection documentation to match server behavior when a collection already exists

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 2.2.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Go Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      If I call the CreateCollection method on a pre-existing collection like:

      coll := client.Database(databaseName).Collection(collectionName)
      
      err := client.Database(databaseName).CreateCollection(context.Background(), collectionName)
      iferr != nil {
          log.Fatalf("failed to create vector store collection: %v", err)
      }

      I would expect it to give me an error as per the documentation:

      If the collection being created already exists, this method will return a mongo.CommandError.

      See https://pkg.go.dev/go.mongodb.org/mongo-driver/v2@v2.0.0/mongo#Database.CreateCollection 

      Either the documentation should be updated, or the error should be returned (or my understanding of Go errors is incorrect).
       

            Assignee:
            matt.dale@mongodb.com Matt Dale
            Reporter:
            julia.tazin@mongodb.com Julia Tazin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: