daily pastebin goal
27%
SHARE
TWEET

Untitled

a guest Jan 20th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package db
  2.  
  3. import (
  4.     "context"
  5.     "github.com/mongodb/mongo-go-driver/mongo"
  6. )
  7.  
  8. func GetDBCollection() (*mongo.Collection, error) {
  9.     client, err := mongo.Connect(context.TODO(), "mongodb://localhost:27017")
  10.     if err != nil {
  11.         return nil, err
  12.     }
  13.     // Check the connection
  14.     err = client.Ping(context.TODO(), nil)
  15.     if err != nil {
  16.         return nil, err
  17.     }
  18.     collection := client.Database("GoLogin").Collection("users")
  19.     return collection, nil
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top