Search code examples
javascriptnode.jsmodelloopback

Loopback Strongloop get ModelName from model instance


Using loopback I need to get the modelName from a model instance. Any Ideas?

var myAccount = new app.models.Account({name: 'ACME'});
var modelName = myAccount.modelName;`
//should get 'Account'

Solution

  • I managed to retrieve the model name by using (where this is the model):

    this.definition.name;