Loopback Strongloop从模型实例中获取ModelName
使用回送我需要从模型实例中获取modelName。 有任何想法吗?
var myAccount = new app.models.Account({name: 'ACME'}); var modelName = myAccount.modelName;` //should get 'Account'
正确的答案是instance.constructor.definition.name
,所以在你的情况myAccount.constructor.definition.name
我设法通过使用(这是模型)检索模型名称:
this.definition.name;