September 2017
Intermediate to advanced
450 pages
11h 24m
English
Now that our API is fully functional with MongoDB, it's very easy to create documents and have them available between application restarts. However, sometimes when working with an application, it's more desirable to make sure the data reverts to a consistent state so that development changes and experimentation don't result in unexpected database states.
One solution to this problem is to generate mock data, and to allow the application to reset its state to this mock data state upon start up. We can use the fabulous library faker.js to help us create some mock post records in our application:
npm install faker --save
All we need to do is use our NODE_ENV process variable as a flag for managing this behavior. We will make ...
Read now
Unlock full access