CouchDB/Cloudant多键查找view

比如view返回所有的记录是这样:

{"total_rows":96,"offset":45,"rows":[
{"id":"02dacaac-9d56-4e5e-8695-6c4a7b88c590","key":["02dacaac-9d56-4e5e-8695-6c4a7b88c590",0],"value":null},
{"id":"02dacaac-9d56-4e5e-8695-6c4a7b88c590:1","key":["02dacaac-9d56-4e5e-8695-6c4a7b88c590",1],"value":null},
{"id":"02dacaac-9d56-4e5e-8695-6c4a7b88c590:2","key":["02dacaac-9d56-4e5e-8695-6c4a7b88c590",2],"value":null},
{"id":"02dacaac-9d56-4e5e-8695-6c4a7b88c590:3","key":["02dacaac-9d56-4e5e-8695-6c4a7b88c590",3],"value":null},
{"id":"02dacaac-9d56-4e5e-8695-6c4a7b88c590:4","key":["02dacaac-9d56-4e5e-8695-6c4a7b88c590",4],"value":null},
{"id":"02dacaac-9d56-4e5e-8695-6c4a7b88c590:5","key":["02dacaac-9d56-4e5e-8695-6c4a7b88c590",5],"value":null},
{"id":"02dacaac-9d56-4e5e-8695-6c4a7b88c590:6","key":["02dacaac-9d56-4e5e-8695-6c4a7b88c590",6],"value":null}
]}


可见key是一个数组, 所以在请求的URL里面,可以这样写:

{URL}/_view/{view_name}?startkey=["02dacaac-9d56-4e5e-8695-6c4a7b88c590",0]&endkey=["02dacaac-9d56-4e5e-8695-6c4a7b88c590",{}]

endkey里面的{}, 可以用来返回一个范围,结尾标志。

你可能感兴趣的:(SQL/NOSQL)