This is an extra exercise for the workshop Building a full-stack application with LoopBack and AngularJS.
Now that we have the first version of our application ready, let's switch the storage backend from an in-memory database to MySQL.
- Install
loopback-connector-mysql
$ npm install loopback-connector-mysql
-
Reconfigure the
dbdatasource to usemysqlconnector instead of the current valuememory(seeserver/datasources.json). -
Modify the code in
server/boot/sample-data.jsso that:
- It first calls
server.dataSources.db.automigrate(cb)to update the MySQL schema. - Skips the Whiskey entry including reviews when it already exists.