Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gomongo doesn't understand result of getlasterror command #3

Open
sbunce opened this issue Nov 2, 2010 · 2 comments
Open

gomongo doesn't understand result of getlasterror command #3

sbunce opened this issue Nov 2, 2010 · 2 comments

Comments

@sbunce
Copy link

sbunce commented Nov 2, 2010

The following code demonstrates this problem.


package main

import (
    "github.com/mikejs/gomongo/mongo"
    "fmt"
    "os"
)

func main() {
    conn, _ := mongo.Connect("127.0.0.1")
    collection := conn.GetDB("test").GetCollection("test_collection")
    doc, _ := mongo.Marshal(map[string]string{
        "_id":     "doc1",
        "title":   "A Mongo document",
        "content": "Testing, 1. 2. 3.",
    })
    collection.Insert(doc)
    doc, err := mongo.Marshal(map [string]string{"getlasterror" : "1"})
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }
    doc, err = conn.GetDB("test_collection").Command(doc)
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }
    m := make(map[string]string)
    err = mongo.Unmarshal(doc.Bytes(), m)
    if err != nil {
//DEBUG, the error is here
        fmt.Println(err)
        os.Exit(1)
    }
    collection.Drop()
}
@vysdel
Copy link

vysdel commented Jan 27, 2011

Try change map [string]string{"getlasterror" : "1"}
to map [string]int{"getlasterror" : 1}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants