我希望通过HTTP REST调用获取模型的属性。我想知道属性名称和数据类型。我怎样才能做到这一点?
一个例子是我想获得user
模型的属性。所以我想进行一次HTTP调用,例如GET
到localhost/users/attributes
,它会返回:
{
id: integer,
username: string,
...
}
我怎样才能做到这一点?感谢。
答案 0 :(得分:0)
实际上,我找到了答案。我在模型的controller.js文件上做了一个路线。我补充说:
module.exports = {
attributes: function (req, res) {
var message = sails.models.categories.attributes;
console.log(message);
res.json(message);
}
};
然后我导航到localhost/<model name>/attributes
。