Have ideas to improve npm?Join in the discussion! »


1.0.1 • Public • Published


Define complex data templates for loopback models

Circle CI Dependencies Coverage Status


  1. Install in you loopback project:

npm install --save loopback-component-templates

  1. Create a component-config.json file in your server folder (if you don't already have one)

  2. Configure options inside component-config.json. (see configuration section)

  "loopback-component-templates": true


  1. Define a template config on a Model._templates property.

  2. Define the templates that generate dummy data. In this example we add a remote method called _template_basic to the Product model.

const faker = require('faker/locale/en')
Product._templates = () => ({
  basic: () => ({
    name: faker.commerce.productName(),
    description: faker.lorem.sentence(),


  • Add way to create related/deep structures
  • Add option to Validate template generators