Building Remote Methods
with Loopback + MySQL

Thoughts: Loopback (description) assists us in building custom remote methods and makes it easy to connect our models with a data source! Before we jump into Loopback, lets get our local database set up!


Setting up your local workstation

Callbacks are just a convention used in Javascript, it is not something that is built into the actual language. Simply, instead of returning some result from a function immediately, it takes some time to produce the result. This is also called an asynchronous (takes some time) function. Callbacks are usually used in I/O implementations, such as remote methods in your Node.js Application!

I have seen that the biggest problem is understanding the execution context, in other words, what order methods (functions) execute. Remember that the order in which execution occurs does NOT read top-to-bottom, rather it jumps around depending on when processes have finished.

2 Rudimentary Coding Principles

Keep your functions SMALL!

That means your function does one thing only! Enough said.

Handle EVERY error!

There are usually 3 different types of errors:

  • syntax (caused by programmer)
  • runtime (caused by programmer)
  • platform (actually isn't the programmer)