When it comes to create, read, update, and delete (CRUD) operations, all save, update, and delete methods need to be converted to the Observable pattern.
Earlier in the chapter, we detailed the endpoint access pattern for CRUD operations in a MongoLab collection. Head back to the Loading exercise and workout data section and revisit the access patterns. We need this now as we plan to create/update workouts.
Before we start the implementation, it is important to understand how MongoLab identifies a collection item and what our ID generation strategy is. Each collection item in MongoDB is uniquely identified in the collection using the _id
property. While creating a new item, either we supply an ID or the server generates one itself. Once _id
is set, it cannot be changed. For our model, we will use the name
property of the exercise/workout as the unique ID and copy the name into the _id
field (hence, there is no autogeneration of _id
). Also, remember that...