Boot files are very important in applications using a LoopBack framework. These files are started when the application is executed, and can perform various kinds of task.
The application already has all the endpoints that it needs. So, let's see how to create a boot file and use another feature from the LoopBack framework to migrate our models to the database.
In this example, we will see how to use the automigrate function to insert some content in the database at the time we start the application:
Tip
You can read more about the LoopBack API at http://apidocs.strongloop.com/.
Inside server/boot, create a new file called create-sample-models.js and place the following content in it:
module.exports = function(app) { // automigrate for models, every time the app will running, db will be replaced with this data. app.dataSources.motorcycleDataSource.automigrate('motorcycle', function(err) { if (err) throw...