Use this strategy to get all documents from the view.

Allowed method

Parameters:

 

Let's assume our database has view called (ByTopic).

router.GET('topics') {
   strategy(DOCUMENTS_BY_VIEW_PAGED) {
      viewName('(ByTopic)')
   }
   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)'
}

 

URL parameters:

 

With route defined above, URL http://server.name/path-to/db.nsf/xsp/.xrest/topics?start=100&count=5 will return 5 documents from view (ByTopic) starting at position 100.

 

Returned JSON will contain an array of documents from the view, such as:

{
    "entries": [
        {
            "date_created": "2017-03-03T11:00+00:00",
            "author": "Martin Jinoch",
            "id": "3B32687545C38F0AC12580D8003DE3E1",
            "topic": "100086"
        },
        {
            "date_created": "2017-03-03T11:00+00:00",
            "author": "Martin Jinoch",
            "id": "B1F591C524952007C12580D8003DE3E0",
            "topic": "100087"
        },
        {
            "date_created": "2017-03-03T11:00+00:00",
            "author": "Martin Jinoch",
            "id": "4B52CCA8B7C3A17FC12580D8003DE3DF",
            "topic": "100088"
        },
        {
            "date_created": "2017-03-03T11:00+00:00",
            "author": "Martin Jinoch",
            "id": "FD09E60D8554821FC12580D8003DE3DE",
            "topic": "100089"
        },
        {
            "date_created": "2017-03-03T11:01+00:00",
            "author": "Martin Jinoch",
            "id": "5A2687611BB5F9EDC12580D8003F43BE",
            "topic": "10009"
        }
    ],
    "start": 100,
    "total": 200001,
    "count": 5
}

Related articles

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

Related issues