Skip to content

Go package to wrap mongo database connection and queries

Notifications You must be signed in to change notification settings

clanbeat/mgowrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#mgowrapper

Go package to wrap mongo database connection and queries

##Usage

Implement interfaces for your structs to use the wrapper for querying, inserting, updating and deleting

package main

import (
  "github.com/clanbeat/mgowrapper"
  "log"
)


func main() {
  var mgo *mongo.Mongo
  var err error
  //set up mongo connection
  mgo, err = mongo.New(os.Getenv("MONGODB_URI"))
  defer mgo.Close()
  if err != nil {
    log.Fatal(err)
  }
  if err := mgo.EnsureIndexes(getMyStructIndexes()); err != nil {
    log.Fatal(err)
  }
}

About

Go package to wrap mongo database connection and queries

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages