O'Reilly logo

AngularJS Services by Jim Lavin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing a CRUD data service

Our application stores its data in a mongodb database hosted by https://mongolab.com. There are 10 different collections that we have to interact with, and these include adjuncts, brewers, equipment, fermentables, hops, mashprofiles, recipes, styles, waterprofiles, and yeast.

We need to create a data service for each one of these collections, but instead of duplicating the code to interact with the MongoLab REST API, it's better to create a single generic service that interacts with MongoLab and then create a data service for each collection that calls the MongoLab API with the specific details for each collection.

The MongoLab REST API consists of the following calls:

List All – Get /databases/{database}/collections/{collection} ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required