gpt4 book ai didi

node.js - Sequelize ,GraphJS : Cannot read property '2' of null

转载 作者:行者123 更新时间:2023-12-03 22:40:36 25 4
gpt4 key购买 nike

当我在模型中定义一个唯一的列时,我将 GraphJS 与 sequelize 一起使用:

const Product = Connection.define('Product', {
label: {
type: Sequelize.STRING,
allowNull: false,
unique: true <--------------
},
description: {
type: Sequelize.TEXT,
allowNull: false
},
price: {
type: Sequelize.FLOAT(6, 3),
}
});

当我尝试 插入 第二个 行时,具有相同的 标签 :
const Mutations = new GraphQLObjectType({
name: 'Mutations',
description: 'All Mutations',
fields: () => {
return {
addProduct: {
type: Product,
args: {
new: {
name: 'New product',
type: ProductInput
}
},
resolve(_, args) {
return Db.models.Product.create(args.new);
}
},
};
}
});

我收到以下错误:
TypeError: Cannot read property '2' of null

有任何想法吗 ?

最佳答案

您似乎不是唯一遇到问题的人:

https://github.com/sequelize/sequelize/issues/6725

https://github.com/feathersjs-ecosystem/feathers-sequelize/issues/71

你也使用mysql吗,如果是,是哪个版本?

似乎在某些版本中有效,而在某些版本中则无效:

https://github.com/feathersjs-ecosystem/feathers-sequelize/issues/71#issuecomment-255192417

关于node.js - Sequelize ,GraphJS : Cannot read property '2' of null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47927712/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com