Sequelize cli 模型创建 [英] Sequelize cli model creation

查看:63
本文介绍了Sequelize cli 模型创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用 sequelize cli 创建 user 模型,但是每当我插入更多参数(如主键和唯一键)时,解析器就会失败.例如:

I've been trying to create a user model using sequelize cli but whenever I insert more parameters like primary key and unique the parser fails. Eg:

npx sequelize model:create --name user --attributes "name:{dataType:string, primaryKey:true}, email:string, address:string" --force

Sequelize CLI [Node: 8.10.0, CLI: 5.4.0, ORM: 5.1.0]


ERROR: Attribute 'name:{dataType:string, primaryKey:true}' cannot be parsed: Cannot read property 'dataType' of undefined

我在 文档 中没有找到任何关于此的参考.有什么办法吗?

I haven't found any reference in the Docs about this. Is there any way to do it?

推荐答案

sequelize model:create --name User --attributes "email:[type:string, unique:true, allowNull: false, { validate: { isEmail:真的}}]

sequelize model:create --name User --attributes "email:[type:string, unique:true, allowNull: false, { validate: { isEmail: true } }]

这篇关于Sequelize cli 模型创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆