Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "time"
- "gopkg.in/mgo.v2"
- "gopkg.in/mgo.v2/bson"
- )
- type Game struct {
- Winner string `bson:"winner"`
- OfficialGame bool `bson:"official_game"`
- Location string `bson:"location"`
- StartTime time.Time `bson:"start"`
- EndTime time.Time `bson:"end"`
- Players []Player `bson:"players"`
- }
- type Player struct {
- Name string `bson:"name"`
- Decks [2]string `bson:"decks"`
- Points uint8 `bson:"points"`
- Place uint8 `bson:"place"`
- }
- func NewPlayer(name, firstDeck, secondDeck string, points, place uint8) Player {
- return Player{
- Name: name,
- Decks: [2]string{firstDeck, secondDeck},
- Points: points,
- Place: place,
- }
- }
- func main() {
- Host := []string{
- "192.168.4.150:27017",
- // replica set addrs...
- }
- const (
- Username = "CMdoctor_agg"
- Password = "cNewtonapple_AGG"
- Database = "order"
- Collection = "record"
- )
- session, err := mgo.DialWithInfo(&mgo.DialInfo{
- Addrs: Host,
- Username: Username,
- Password: Password,
- })
- fmt.Println(err)
- c := session.DB(Database).C(Collection)
- fmt.Println(c)
- type Result struct {
- Type string `bson:"type"`
- TempID float64 `bson:"tempID"`
- }
- r := Result{}
- fmt.Println("Hello")
- fmt.Println(c.Find(bson.M{"type": "test"}).One(&r))
- fmt.Println(r.TempID)
- fmt.Println(r.Type)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement