Reputation: 41
in couchbase, I have a document in beer-sample bucket
it 's like following
{
"uid": "kingarthur",
"email": "[email protected]",
"interests": [
"Holy Grail",
"African Swallows"
]
}
while I try to get the result from my source code application, I can get the result. here is sample code
// Use query
query := gocb.NewN1qlQuery("SELECT * FROM `beer-sample` WHERE email=?")
email := `[email protected]`
params := []interface{}{
email}
rows, err := bucket.ExecuteN1qlQuery(query, params)
if err != nil {
fmt.Println(err)
return
}
var row interface{}
for rows.Next(&row) {
fmt.Printf("Row: %v", row)
}
but if I run N1SQL command from the cbq cli, I always get null result, anyone know why?
Upvotes: 2
Views: 176
Reputation: 41
resolve, it is caused by the character ``, we must use the single quote, or double quote
cbq> SELECT * FROM `beer-sample` WHERE email='[email protected]';
{
"requestID": "17507176-519e-4b42-9808-aa3b855f4fb9",
"signature": {
"*": "*"
},
"results": [
{
"beer-sample": {
"email": "[email protected]",
"interests": [
"Holy Grail",
"African Swallows"
],
"uid": "kingarthur"
}
}
],
"status": "success",
"metrics": {
"elapsedTime": "7.399438091s",
"executionTime": "7.39925411s",
"resultCount": 1,
"resultSize": 266
}
}
Upvotes: 2