concept document in category angular

This is an excerpt from Manning's book Getting MEAN with Mongo, Express, Angular, and Node.js 2ED.
MongoDB is not like that! MongoDB is a document store. The concept of rows still exists, but columns are removed from the picture. Rather than a column defining what should be in the row, each row is a document, and this document both defines and holds the data itself. Table 1.2 shows how a collection of documents might be listed. (The indented layout is for readability, not a visualization of columns.)
Table 1.2. Each document in a document database defines and holds the data, in no particular order.
firstName: "Simon" middleName: "David" lastName: "Holmes" nickname: "Si" lastName: "Panayiotou" middleName: "June" firstName: "Sally" maidenName: "Holmes" firstName: "Rebecca" lastName: "Norman" nickname: "Bec" This less-structured approach means that a collection of documents could have a wide variety of data inside. In the next section, you’ll look at a sample document to get a better idea of what we’re talking about.
When the subdocument has been added, the parent document must be saved because subdocuments can’t be saved on their own. To save a document, Mongoose has a model method save(), which expects a callback with an error parameter and a returned object parameter. The following code snippet shows this method in action:
location.save((err, location) => { if (err) { res .status(400) .json(err); } else { let thisReview = location.reviews[location.reviews.length - 1]; #1 res .status(201) .json(thisReview); } });The document returned by the save method is the full parent document, not the new subdocument alone. To return the correct data in the API response—that is, the subdocument—you need to retrieve the last subdocument from the array 1.
When adding documents and subdocuments, you need to keep in mind any effect this action may have on other data. In Loc8r, for example, adding a review adds a new rating, and this new rating affects the overall rating for the document. On the successful save of a review, you’ll call another function to update the average rating.
Mongoose makes deleting a document in MongoDB extremely simple by giving you the method findByIdAndRemove(). This method expects a single parameter: the ID of the document to be deleted.
Listing 6.11. Deleting a document from MongoDB, given an ID
const locationsDeleteOne = (req, res) => { const {locationid} = req.params; if (locationid) { Loc .findByIdAndRemove(locationid) #1 .exec((err, location) => { #2 if (err) { return res #3 .status(404) .json(err); } res #3 .status(204) .json(null); } ); } else { res .status(404) .json({ "message": "No Location" }); } };That’s the quick and easy way to delete a document, but you can break it into a two-step process or, if you prefer, find it and then delete it. This gives you the chance to do something with the document before deleting (if you need to). This is demonstrated in the following code snippet:
Loc .findById(locationid) .exec((err, location) => { // Do something with the document location.remove((err, loc) => { // Confirm success or failure }); } );