Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagegroovy
linenumberstrue
router.GET('topics/filter/{filterValue}') {
   strategy(DOCUMENTS_FROM_VIEW_BY_KEY) {
      viewName('(ByTopic)')
      keyVariableName('filterValue')      
mode('exact')
   }
   mapJson 'id', json:'id', type:'STRING', isformula:true, formula:'@DocumentUniqueID'
   mapJson 'date_created', json:'date_created', type:'DATETIME', isformula:true, formula:'@Created'
   mapJson 'topic', json:'topic', type:'STRING'
   mapJson 'author', json:'author', type:'STRING', isformula:true, formula:'@Name([CN]; @Author)'
}

...

With route defined above, URL http://server.name/path-to/db.nsf/xsp/.xrest/topics/filter/test will return all documents from view (ByTopic) with field Topic starting with "test". If mode('exact') was specified, it would return just those document with Topic "test".

 

For example, if only one document matches this filter, we'll get this JSON:

...