gpt4 book ai didi

mysql - 羽毛 - PATCH 时 where 子句中的未知列

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

我正在为 mysql 数据库使用 Sequelize。
当我使用 Postman 的 Find 函数时,它返回:

{
"total": 1,
"limit": 10,
"skip": 0,
"data": [
{
"id": "1",
"latestNewsId": "f8b53a32-b729-41f8-9888-df2b71e91177"
}
]
}
然后我尝试通过 latestNewsId 使用 Patch 修改 Postman 中的 id
PATCH localhost:3030/latest_news_featured/1

Body:
{
"latestNewsId": "f8b53a32-b729-41f8-9888-df2b71e12345"
}
这是当时发生的错误:
{
"name": "GeneralError",
"message": "Unknown column 'latest_news_featured.undefined' in 'where clause'",
"code": 500,
"className": "general-error",
"errors": {}
}
我不知道为什么会发生这种情况,因为我检查并确认了数据库中存在 idlatestNewsId
latest_news_featured.models.js
const Sequelize = require('sequelize');
const DataTypes = Sequelize.DataTypes;

module.exports = function (app) {
const sequelizeClient = app.get('sequelizeClient');
const latestNewsFeatured = sequelizeClient.define('latest_news_featured', {
id: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: 1,
primaryKey: true
},
latestNewsId: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
allowNull: false,
}
}, {
hooks: {
beforeCount(options) {
options.raw = true;
}
}
});

latestNewsFeatured.associate = function (models) { };
return latestNewsFeatured;
};

最佳答案

latest-news-featured.class 中,当我评论 this.options = options || {}; 时,它​​立即起作用。
我不确定原因,所以我把它留在这里,希望它可以帮助其他有同样问题的人。
最新消息-featured.class.js

const { Service } = require('feathers-sequelize');

exports.LatestNewsFeatured = class LatestNewsFeatured extends Service {

constructor (options,app) {
super(options, app);
this.app = app;
//this.options = options || {}; //Comment this line to make it works
}
...

...
};

关于mysql - 羽毛 - PATCH 时 where 子句中的未知列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67757707/

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