gpt4 book ai didi

couchdb - 如何在 CouchDB 中使用多个 WHERE 和 OR 子句创建 View

转载 作者:行者123 更新时间:2023-12-02 15:50:55 24 4
gpt4 key购买 nike

我如何创建一个与这样的 SQL 查询等效的 View ?

SELECT * FROM 存储桶 WHERE (uid='$uid' AND Accepted='Y') OR (uid='$uid' ANDauthorid='$logginid')

我的数据是这样存储的:

{
"id": 9476183,
"authorid": 85490,
"content": "some text here",
"uid": 41,
"accepted": "Y",
"time": "2014-12-09 10:44:01",
"type": "testimonial"
}

最佳答案

function(doc) {
if (doc.accepted == 'Y') {
emit(doc.uid, null);
}
emit([doc.uid, doc.authorid], null);
}

一个请求就足够了。您可以使用带有参数 keys:[[uid,authorid], uid] 的 POST 来点击 @Simon 编写的 View (上面转载)。

参见http://docs.couchdb.org/en/latest/api/ddoc/views.html#post--db-_design-ddoc-_view-view了解模式详细信息。

关于couchdb - 如何在 CouchDB 中使用多个 WHERE 和 OR 子句创建 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28345751/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com