Is there any way to list all the properties on a model in Loopback? I'd like to be able to get more than just the name when I call loopback.models() to get the model list. I'd like to build a generic dashboard that will automatically generate forms to edit my models, but to do so I need to be able to enumerate model properties.
That's javascript, so in a boot script like ./server/boot/printall.js
you can explore all props of all models
module.exports = function(app) {
for(var i = 0 ; i < app.models.length ; i++) {
for(prop in app.models[i]) {
console.log(prop)
}
}
}
To build the dashbord client-side, I would recommend to use the swagger.json file that contains all of these information and is accessible client-side at http://localhost:3000/explorer/resources
(loopback 1.2) or http://localhost:3000/explorer/swagger.json
(loopback 2.0)