node.js - couchdb - how to search by array -


i have documents following format:

{  url: 'some-unique-url',  name: 'some-name' } 

what need select documents has specific url supplying array contains url's need select:

['some-unique-url', 'another-url'] 

here's view looks like:

function(doc) {   if(doc.type == 'message'){     emit([doc.url], null);   } } 

and here's node.js code. i'm using nano.

db.view('message', 'by_url', {'key': urls}, function(err, body){     res.send(body); }); 

this works if have 1 item in array add item, here's get:

{"total_rows":18,"offset":11,"rows":[]} 

i tried startkey , endkey works acts same way previous one:

db.view('message', 'by_url', {'startkey': online_users_ids, 'endkey': [online_users_ids, {}]}, function(err, body){     res.send(body); }); 

is i'm trying possible couchdb , nano? if not, what's closest thing can without losing performance? in advance!

you need use keys instead of key documented in couchdb api reference.

db.view('message', 'by_url', {'keys': urls}, function(err, body){     res.send(body); }); 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -