How would I creat a view equivalent to a SQL query like this?
SELECT * FROM bucket WHERE (uid='$uid' AND accepted='Y') OR (uid='$uid' AND authorid='$logginid')
My data is stored this way:
{
"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);
}
One request is enough. You can tap view written by @Simon (reproduced above) using POST with param keys:[[uid, authorid], uid].
See http://docs.couchdb.org/en/latest/api/ddoc/views.html#post--db-_design-ddoc-_view-view for mode details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With