Skip to content

Instantly share code, notes, and snippets.

@bajtos
Created September 9, 2014 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bajtos/e279b39f38e01f85da97 to your computer and use it in GitHub Desktop.
Save bajtos/e279b39f38e01f85da97 to your computer and use it in GitHub Desktop.
Switch the full-stack LoopBack AngularJS applications to MySQL database

This is an extra exercise for the workshop Building a full-stack application with LoopBack and AngularJS.

Switch to MySQL

Now that we have the first version of our application ready, let's switch the storage backend from an in-memory database to MySQL.

  1. Install loopback-connector-mysql
$ npm install loopback-connector-mysql
  1. Reconfigure the db datasource to use mysql connector instead of the current value memory (see server/datasources.json).

  2. Modify the code in server/boot/sample-data.js so that:

  • It first calls server.dataSources.db.automigrate(cb) to update the MySQL schema.
  • Skips the Whiskey entry including reviews when it already exists.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment