In the golang Couchbase SDK there are N1QL select examples documented with examples like this:
myQuery := gocb.NewN1qlQuery("SELECT airportname, city, country FROM `travel-sample` " +
"WHERE type='airport' AND city=$1 ")
myParams = append(myParams, []interface{}{"Reno"})
rows, err := bucket.ExecuteN1qlQuery(myQuery, myParams)
When I try it with the following, it doesn't find any records.
query := gocb.NewN1qlQuery("SELECT * FROM `bucket` WHERE META().id LIKE 'TD:$1:%'")
rows, err := r.Bucket.ExecuteN1qlQuery(query, []interface{}{userid})
if err != nil {
return nil, err
}
But this does work and also works in the Couchbase console:
query := gocb.NewN1qlQuery("SELECT * FROM `bucket` WHERE META().id LIKE 'TD:"+userid+":%'")
rows, err := bucket.ExecuteN1qlQuery(query, nil)
Am I doing anything obviously wrong here?
While the non-parametised option works I'd like to use the parametised one and mark it as a prepared statement with query.AdHoc(false)