Page Contents

LoopBack applications come with a small set of built-in models. To create database tables for these models, follow the general procedure for  creating a database schema from models using auto-migration.

To create tables for LoopBack built-in models, follow this procedure:

  1. Follow the basic procedure in Attaching models to data sources to change from the in-memory data source to the  database you want to use.

  2. Create server/create-lb-tables.js file with the following:

    var server = require('./server');
    var ds = server.dataSources.db;
    var lbTables = ['User', 'AccessToken', 'ACL', 'RoleMapping', 'Role'];
    ds.automigrate(lbTables, function(er) {
      if (er) throw er;
      console.log('Loopback tables [' - lbTables - '] created in ',;
  3. Run the script manually:

    $ cd server
    $ node create-lb-tables.js