apache / nano

Nano is now part of Apache CouchDB. Repo moved to https://GitHub.com/apache/couchdb-nano

Home Page:https://github.com/apache/couchdb-nano

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is the keys in view function based on? Is it the key you emit in the views/map function?

flynsequeira opened this issue · comments

the param in view function - {keys: [key1,key2]}
is the key based on the emit part of the view function? If so, will I be able to set anything as key, like the _id?
views: {
"all": {
"map": "function(doc){if(doc) emit(doc._id,null)}"
}
}
If this is not the case, could you please clarify as to what keys refers to OR how I can query based on an array of id?

Hi @flynsequeira,

yes, key is what you emit as key in your view function. You can emit everything you like as keys, I often use arrays. Normally you don't need to set up a view with _id keys, because the built in _all_docs view has _id as key. You can use nanos list API for that.

See http://docs.couchdb.org/en/2.1.0/api/ddoc/views.html for information about how to query keys.