sequelize我与postgresql和 logger一起使用winston。这是我的代码:
logging: e => logger('sequelize').info(e)
Run Code Online (Sandbox Code Playgroud)
这会记录如下结果:
INSERT INTO "test" ("id","aa","bb","cc") VALUES (DEFAULT,$1,$2,$3) RETURNING *; // I don't want this
Run Code Online (Sandbox Code Playgroud)
如何更改以使输出像这样?
INSERT INTO "test" ("id","aa","bb","cc") VALUES (DEFAULT,"AA","BB","CC") RETURNING *; // I want this
Run Code Online (Sandbox Code Playgroud) 我在反应功能组件中有以下代码。当我单击按钮并运行处理程序时,发生错误:
Invalid hook call. Hooks can only be called inside of the body of a function component.
const handleClick = () => {
const [count, setCount] = useState(x); // this is wrong
};
Run Code Online (Sandbox Code Playgroud)
我试图寻找修复,有人建议:
const [count, setCount] = useState(0);
const handleClick = () => {
setCount(x); // setCount is ok, but I cannot set other dynamic states
};
Run Code Online (Sandbox Code Playgroud)
但是,我的count状态是动态的,我无法从一开始就全部初始化。当我使用类组件时,这很容易。
// old syntax from class components
state = {
count: 0
};
const handleClick = () => {
this.setState({ …Run Code Online (Sandbox Code Playgroud)