Page tree
Skip to end of metadata
Go to start of metadata

Use this strategy to get all documents from the view.

Allowed method

  • GET

Parameters:

  • databaseName(String databaseName): name of the database to read data from, use "server!!path/database.nsf" format; when omitted, current database is used
  • viewName(String viewName): name of the view; mandatory

 

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:

  • count: number or records to return, default is 10
  • start: position in the view to start from, default value is 1

 

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
}