Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "log"
- "time"
- "github.com/globalsign/mgo"
- "github.com/globalsign/mgo/bson"
- )
- func main() {
- var pruebas []bson.D
- c := NewConnection()
- err := c.Find(nil).All(&pruebas)
- if err != nil {
- log.Fatal(err)
- }
- log.Println(pruebas)
- }
- func NewConnection() *mgo.Collection {
- info := &mgo.DialInfo{
- Addrs: []string{"localhost:27017"},
- Timeout: 10 * time.Second,
- Username: "oneloop",
- Password: "oneloop360",
- }
- session, err := mgo.DialWithInfo(info)
- if err != nil {
- panic(err)
- }
- session.SetMode(mgo.Monotonic, true)
- collection := session.DB("prueba").C("prueba")
- return collection
- }
Add Comment
Please, Sign In to add comment