Golang API Executing Query

http://www.aerospike.com/docs/client/go/usage/query/query.html

Executing Query provides Bins as result. Can I take object as result?

Now I use it:

stmt := as.NewStatement("bidder", "banner")
stmt.Addfilter(as.NewEqualFilter("CampaignID", id))

rs, err := db.client.Query(nil, stmt)
if err != nil {
	return nil
}

banner := make(map[int]*Banner)

for res := range rs.Results() {
	if res.Err != nil {
		panic(res.Err)
	}

	banner[res.Record.Bins["ID"].(int)] = &Banner{
		ID:         res.Record.Bins["ID"].(int),
		CampaignID: res.Record.Bins["CampaignID"].(int),
		Shows:      res.Record.Bins["Shows"].(int),
		Name:       res.Record.Bins["Name"].(string),
		Width:      res.Record.Bins["Width"].(string),
		Height:     res.Record.Bins["Height"].(string),
		Type:       res.Record.Bins["Type"].(string),
	}
}

And I need duplicate key in a bin name, becaus query don’t return key. This is the right decision?

At the moment QueryObject is not supported, but it is coming very soon.

Regarding the query returning the key, you need to set the WritePolicy.SendKey to true to send the original keys to the server. If the key is sent to the server, then both scan and query operations will return the keys.

Ok, thanks.

At this page http://www.aerospike.com/docs/client/go/usage/query/sindex.html

task, err := client.CreateIndex(null, "foo", "bar", 
    "idx_foo_bar_baz", "baz", aerospike.NUMERIC)

// to block until the Index is created
for err := range task.OnComplete(); err != nil {
    // deal with the error here
}
// task is completed successfully

It’s wrong code. Parse error! It may need to write code like this:

err = <-task.OnComplete()
	if err != nil {
		return nil, err
	}