【发布时间】:2013-07-26 19:17:35
【问题描述】:
我在 java 中使用 couchbase API
View view = client.getView("dev_1", "view1");
Query query = new Query();
query.setIncludeDocs(true);
query.setKey(this.Key);
ViewResponse res=client.query(view, query);
for(ViewRow row: res)
{
// Print out some infos about the document
a=a+" "+row.getKey()+" : "+row.getValue()+"<br/>";
}
return a;
以及couchbase中的java脚本视图
function (doc,meta) {
emit(meta.id,doc);
}
所以,当我删除语句 query.setkey(this.Key) 时,它会返回所有表,我在这里缺少什么.. 如何更改函数以仅反映键中提到的表名
【问题讨论】:
-
1.什么是
this.Key变量,它在哪里定义以及它有什么值? 2. “桌子”是什么意思? Couchbase 没有任何桌子。 (举个例子)。 3.如果你使用setIncludeDocs(true);,你应该使用emit(meta.id,null);而不是emit(meta.id,doc); -
this.Key 有表名,即我的 JSON 文档中有一个名为 table 的字段,所以我想查询 doc.table=this.key 获取结果集并返回它
-
所以尝试发出(doc.table,null);
标签: javascript couchbase membase