我正在尝试使用Sequelize在PostgreSQL中创建一个名为Post的表。我有以下代码来生成表:
const Post = sequelize.define('post', {
community: Sequelize.STRING,
block: Sequelize.INTEGER,
fullPermlink: {
type: Sequelize.STRING,
primaryKey: true
},
featured: Sequelize.BOOLEAN,
featurer: Sequelize.STRING,
pinned: Sequelize.BOOLEAN
},{
indexes:[
{
unique: false,
fields:['block']
}
]
});
运行此命令,数据库将正确地为block列创建索引,但由于某种原因,它还会尝试将indexes
创建为一行本身。这是启用日志记录后提供的日志:
Executing (default): CREATE INDEX "posts_block" ON "posts" ("block")
Executing (default): CREATE TABLE IF NOT EXISTS "pinnedposts" ("id" SERIAL , "community" VARCHAR(255), "fullPermlink" VARCHAR(255), "indexes" [object Object], "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, PRIMARY KEY ("id"));
Unhandled rejection SequelizeDatabaseError: syntax error at or near "["
这对我来说似乎是一个很奇怪的错误,感谢您的提前帮助!