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

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Use this strategy to select document from the database by UNID.

Allowed method

  • GET

Parameters:

  • keyVariableName(String keyVariableName): name of the variable name in route to read value from; mandatory

 

router.GET('topics/{id}') {
   strategy(SELECT_DOCUMENT_BY_UNID) {
      keyVariableName('id')
   }
   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'
}

 

With route defined above, URL http://server.name/path-to/db.nsf/xsp/.xrest/topics/54502859C07299C7C12580D8006404F4 will return this JSON:

    {
    "date_created": "03\/03\/2017 19:12:28",
    "author": "Martin Jinoch",
    "categories": [
        "category1",
        "category2"
    ],
    "topic": "test"
}

 

  • No labels