简体   繁体   中英

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'

正确的答案是instance.constructor.definition.name ,因此在您的情况下, myAccount.constructor.definition.name

我设法通过使用(其中是模型)来检索模型名称:

this.definition.name;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM