我想创建一个 cli 来创建管理员用户 我在 api/models/User.js 中设置了用户模型
并在气候中
var User, program;
program = require("commander");
User = require("../api/models/User");
program.version("0.0.1");
program.command("create_user").description("Create a user into database").action(function() {
return console.log(User);
});
program.parse(process.argv);
用户日志是:
User = {
attributes: {
username: "string",
password: "string",
}
};
并且没有可用的水线方法。
您可以使用sails run <command>
.
简单地创建<appPath>/commands/index.js
包含以下内容:
module.exports = {
testcommand: function (done) {
// .. your code
console.log('this is my testcommand');
done();
}
}
现在你可以运行了sails run testcommand
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)