1

I'm trying to PUT my GridDB container (a simple container for users on my website) but it's having issues.

I've confirmed that the sample code for the go_client works so it's not an issue of improper build or anything of that sort.

func getAdminUsers(c echo.Context) error {
    var tmp []interface{}

    col, err1 := gridstore.GetContainer("users")
    if err1 != nil {
        fmt.Println("get container failed")
    }

col.SetAutoCommit(true)

// Create normal query
    query, err := col.Query("SELECT *")
    if err != nil {
        fmt.Println("create query failed")
    }
    //Execute query
    rs, err := query.Fetch(true)
    if err != nil {
        fmt.Println("create rs from query failed")
    }
    for rs.HasNext() {
        // Update row
        rrow, err := rs.NextRow()
        if err != nil {
            fmt.Println("NextRow from rs failed")
        }
        tmp = rrow
        fmt.Println("Person: name=", rrow[0], " status=", rrow[1], " count=", rrow[2], " lob=", rrow[3])
    }

    col.Commit()
    fmt.Println(tmp)
    return c.Render(http.StatusOK, "admin", "admin")
}

My container is properly being written but for some reason the querying isn't working. This is rather basic code so I expect there's some minor detail I'm missing somewhere.

As of now, I'm getting errors here: "get container failed". My error could either be from writing or querying, though I suspect it's from querying.

Codelicious
  • 355
  • 1
  • 10
Gopheritis
  • 72
  • 5

1 Answers1

0

Can you try initializing your container by using the CreateContainerInfo instead? It will create container if it doesn't exist, but if it does exist, it's a more robust method of calling your container.

conInfo, _ := griddb_go.CreateContainerInfo("Users",
            [][]interface{}{
                {"email", griddb_go.TYPE_STRING},
                {"password", griddb_go.TYPE_BLOB}},
            griddb_go.CONTAINER_COLLECTION,
            true)
        col, _ := gridstore.PutContainer(conInfo, false)
Codelicious
  • 355
  • 1
  • 10