Question

I have this ViewDefinition:

""" Models id."""
models = ViewDefinition('models', 'by_authors', """
function(doc) {
  if (doc.type == "definition") {
    for (var i = 0; i < doc.authors.length; i++) {
      var author = doc.authors[i];
      emit(author, doc._id);
    }
  }
}""")

I am calling it like so:

models = []
for principal in principals:
    models += [d.value for d in views.models(self._db)[principal].rows]
return list(set(models))

How can I ask for a list of keys instead and call it like:

models = [d.value for d in views.models(self._db)[*principals].rows]
Was it helpful?

Solution

Well the solution is quite simple also I had to read the source code to be able to find it.

models = [d.value for d in views.models(self._db, keys=principals).rows]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top