Use this strategy to get documents from the database by specified formula.

Allowed method

Parameters:

 

router.GET('topics/cat1cat2') {
 strategy(DOCUMENTS_BY_FORMULA) {
   selectQuery('SELECT Form=\"MainTopic\" & @Contains(Categories;\"category1\":\"category2\")')
 }
 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)'
 mapJson 'categories', json:'categories', type:'ARRAY_OF_STRING'
} 

 

URL parameters:

 

With route defined above, URL http://server.name/path-to/db.nsf/xsp/.xrest/topics/cat1cat2?count=5 will return all documents from database, that match the selection formula.

Returned JSON:

{
  "entries": [
        {
      "date_created":"2017-03-03T18:28+00:00",
      "author":"Martin Jinoch",
      "id":"54502859C07299C7C12580D8006404F4",
      "categories": [
        "category1"
      ]
    },
        {
      "date_created":"2017-03-11T13:11+00:00",
      "author":"Martin Jinoch",
      "id":"DCEFCAE41C0C9815C12580E0004BD296",
      "categories": [
        "category1",
        "category2"
      ]
    }
  ],
  "start":1,
  "total":2,
  "count":2
}

 

Related articles

Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.

Related issues