When I implement a query by selecting all the elements using * operator, the query is not mapped to the struct.
query := gocb.NewN1qlQuery("SELECT * FROM `item-bucket` WHERE itemBarcode=$1")
queryParams = append(queryParams, itemBarcode)
rows, err := itemBucket.ExecuteN1qlQuery(query, queryParams)
var row ItemEntity
for rows.Next(&row) {
fmt.Printf("Results: %+v\n", row)
}
However, when I add each of the fields into the query, it is directly mapped.
query := gocb.NewN1qlQuery("SELECT itemBarcode, color, price FROM `item-bucket` WHERE itemBarcode=$1")
queryParams = append(queryParams, itemBarcode)
rows, err := itemBucket.ExecuteN1qlQuery(query, queryParams)
var row ItemEntity
for rows.Next(&row) {
fmt.Printf("Results: %+v\n", row)
}
Is there a way to map directly to struct using the * operator?
The Go version of the project is 1.6