在couchbase中,我在啤酒样本桶中有一份文件
就像关注
{
"uid": "kingarthur",
"email": "kingarthur@couchbase.com",
"interests": [
"Holy Grail",
"African Swallows"
]
}
当我尝试从源代码应用程序中获取结果时,我可以得到结果。这是示例代码
// Use query
query := gocb.NewN1qlQuery("SELECT * FROM `beer-sample` WHERE email=?")
email := `kingarthur@couchbase.com`
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)
}
但如果我从cbq cli运行N1SQL命令,我总是得到null结果,有人知道为什么吗?
答案 0 :(得分:1)
决心 它是由字符``引起的,我们必须使用单引号或双引号
CBQ> SELECT * FROM beer-sample
WHERE email =' kingarthur@couchbase.com' ;;
{
" requestID":" 17507176-519e-4b42-9808-aa3b855f4fb9",
"签名":{
" ":" "
},
"结果":[
{
" beer-sample":{
"电子邮件":" kingarthur@couchbase.com",
"兴趣":[
"圣杯",
"非洲燕子"
]
" uid":" kingarthur"
}
}
]
"状态":"成功",
" metrics":{
" elapsedTime":" 7.399438091s",
" executionTime":" 7.39925411s",
" resultCount":1,
" resultSize":266
}
}