MongoDB database structure
To build our application, we will have to perform data reads and updates on the server in the database. For example, each click on the Add Element button should insert a new line into the displayed HTML page but should also insert a new document into MongoDB’s elements
collection. Indeed, each document of the elements
collection will represent the text of the element displayed in the list on the screen.
Note
To access the MongoDB database, you start by installing the mongoose module (see the previous chapter), which allows you to manipulate database documents in JavaScript.
To do this, type the npm install mongoose
command (from the main directory, list
, of the Express application).
The elements
collection will be the one that will store the list items in MongoDB. A document in the elements
collection will consist of its text associated with the text
property. Each document will also have the _id
property, whose unique value is assigned...