最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Sequelize,GraphJS:无法读取null的属性“2”

运维笔记admin10浏览0评论

Sequelize,GraphJS:无法读取null的属性“2”

Sequelize,GraphJS:无法读取null的属性“2”

当我在模型中定义一个唯一的列时,我正在使用带有sequelize的GraphJS:

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/sequelize/sequelize/issues/6725

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

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

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

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

发布评论

评论列表(0)

  1. 暂无评论