title: Official mongo-go-driver using sessions
body: <p>Is there any example of using sessions with official mongodb driver for golang? I am trying to use sessions to take advantage from transactions and it seems that just reading tests on github I can’t find the way to do it.</p>
  
  <p>To be more specific I am struggling now with this:</p>
  
  <pre><code>session, err := pool.StartSession()                                              
     if err != nil {                                                                  
       log.Println("Could not create db session", err)                                
       return events.APIGatewayProxyResponse{                                         
         Body:       err.Error(),                                                     
         StatusCode: http.StatusInternalServerError,                                  
       }, err                                                                         
     }                                                                                
     ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)          
     defer cancel()                                                                   
     defer session.EndSession(ctx)                                                    
  
      var db *mongo.Database                                                           
  </code></pre>
  
  <p>Everything fine with code above but when I do:</p>
  
  <blockquote>
    <p><code>db = session.Database("testrest")</code></p>
  </blockquote>
  
  <p>It gives the error: </p>
  
  <blockquote>
    <p>session.Database undefined (type mongo.Session has no field or method
    Database)</p>
  </blockquote>
  
  <p>Which seems to work with mgo package… How do I select the database and run queries with session?</p>