write a example of how to write restfulservice using database