couchDB查询 [英] couchDB queries

查看:123
本文介绍了couchDB查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个ouchDB新手,没有运气从我的观点中得到过滤的响应.无论查询如何,我总能得到整个视图,这是没有道理的.

I am a couchDB noob and am having no luck getting a filtered response from my views. No matter the query I always get the whole view, and this makes no sense.

例如在用户数据库中...我尝试了此地图功能,只是为了了解它的工作原理.

For example in a users database... I tried this map function, just to get a feel for how it works.

    login: {
        map: function(doc){
            if (doc.firstName && doc.lastName)
                emit(doc.firstName, doc.lastName);
        }
    }

教科书的东西对吗?

但是当我发布一个看起来像这样的查询时...

But when I POST a query that looks like this...

    {key: ["Mo"]} ... or ... {key:"Mo"}

我得到了所有...整个视图!甚至这个...

I get back everything... the whole view! Even this...

    {startkey:["Mo"], endkey:["Mo"]} ... or ... {startkey:"Mo", endkey:"Mo"}

将查询编码到url中并执行GET可以得到相同的响应!

Encoding the query into the url and doing a GET gives me the same response!!

我该怎么做才能使它起作用?有什么特别的酱料?我需要牺牲动物吗?还是我只是不够放松?

What do I do to make this work? What's the special sauce? Do I need to sacrifice an animal? Or am I just not relaxing hard enough?

推荐答案

因此,为了清楚起见,您的网址应如下所示:

So, just to be clear, your URL should look like this:

http://your.server/your_db/_design/view_id/_view/view_name?key="Mo"

大多数浏览器会将这些"正确编码为%22 s

And most browsers will encode those "s correctly into %22s

这篇关于couchDB查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆