Node.js 使用Sequelize在邮递员抛出约束错误上发布表单数据

Node.js 使用Sequelize在邮递员抛出约束错误上发布表单数据,node.js,sequelize.js,postman,multipartform-data,multer,Node.js,Sequelize.js,Postman,Multipartform Data,Multer,我试图在Postman中发布一个包含文本、int和文件的多部分表单数据。我想我已经把我的图像正确地插入到了文件中,但是因为在邮递员的表单数据元素中只有文本和文件字段,所以int数字周围有“”,它们所在的框是文本值 这会导致约束错误的后果吗?在原始POST部分中,插入的数字没有“”符号,因此它们被识别为INT值 或者这可能与我的模型中的文本数据类型没有注册我试图插入的url值有关。我看到的大多数教程都有BLOB-long数据类型,但是pgadmin Postgres认为这是BYTEA export

我试图在Postman中发布一个包含文本、int和文件的多部分表单数据。我想我已经把我的图像正确地插入到了文件中,但是因为在邮递员的表单数据元素中只有文本和文件字段,所以int数字周围有“”,它们所在的框是文本值

这会导致约束错误的后果吗?在原始POST部分中,插入的数字没有“”符号,因此它们被识别为INT值

或者这可能与我的模型中的文本数据类型没有注册我试图插入的url值有关。我看到的大多数教程都有BLOB-long数据类型,但是pgadmin Postgres认为这是BYTEA

exports.createDiveSpot = async (req, res) => {
    try {
        console.log(diveSpot);
        // if (req.diveSpot == undefined) {
        //     return res.send(`You must select a file.`);
        // }
        diveSpot.create({
            diveLocation: req.body.diveLocation,
            diveRegionID: req.body.diveRegionID,
            diveSpotTypeID: req.body.diveSpotTypeID,
            diveSpotDescription: req.body.diveSpotDescription,
            photos: "/assets/" + req.file.photos
        }).then((diveSpot) => {
                fs.writeFileSync(
                    __basedir + "/assets/" + diveSpot.diveLocation,
                    diveSpot.photos
            );
            return res.send(`File has been uploaded.`);
        });
    } catch (error) {
        console.log(error);
        return res.send(`Error when trying upload images: ${error}`);
    }
};

Drop and re-sync database with { force: true }
IleSainteMarieSpot.jpg
diveSpots
Executing (default): INSERT INTO "diveSpots" ("diveSpotID","diveLocation","diveRegionID","diveSpotTypeID","diveSpotDescription","photos") VALUES (DEFAULT,$1,$2,$3,$4,$5) RETURNING *;
Unhandled rejection SequelizeUniqueConstraintError: Validation error
backend\node_modules\sequelize\lib\dialects\postgres\query.js:324:18)
backend\node_modules\sequelize\lib\dialects\postgres\query.js:72:18
backend\node_modules\sequelize\node_modules\bluebird\js\release\util.js:16:23)