我到处寻找这个问题,但我还没找到。 我正在使用Sequelize for Postgres,我试图将内容添加到模型中。它不会抛出任何错误,只是警告说基于字符串的操作已被弃用,但这不是一个操作。
sequelize deprecated基于String的运算符现已弃用。请使用基于符号的运算符以提高安全性,请在http://docs.sequelizejs.com/manual/tutorial/querying.html#operators
了解更多信息这是我的模型和.create代码
const Sequelize = require('sequelize');
const sequelizeInstance = new Sequelize('journal_entries', 'KupidoExportLLC',
{
dialect: 'postgres'
});
module.exports = function(sequelizeInstance, DataTypes){
const Entries = sequelizeInstance.define('entries', {
user: Sequelize.STRING,
title: Sequelize.STRING,
content: Sequelize.TEXT
})
Entries.sync().then(function(){
Entries.create({
user: 'I need to get this to work',
title: 'Ill be really happy when this does work',
content: 'It will work this time'
})
});
return Entries;
}
这是我的命令行显示的内容
sequelize deprecated基于String的运算符现已弃用。请使用基于符号的运算符以获得更好的安全性,请阅读http://docs.sequelizejs.com/manual/tutorial/querying.html#operators node_modules / sequelize / lib / sequelize.js:242:13
当我去看我的桌子时,它是空的
journal_entries=# SELECT * FROM entries;
id | user | title | content | createdAt | updatedAt
----+------+-------+---------+-----------+-----------
(0 rows)
我不知道它还能是什么
答案 0 :(得分:3)
您需要关闭警告。
在config.JSON文件中或(如果已在同一文件中初始化连接) 按照给出的那样关闭警告:
IN Config.JSON
{
"development": {
"username": "root",
"password": "12345",
"database": "fasttrack",
"host": "localhost",
"dialect": "mysql",
"define": {
"timestamps": false
},
"operatorsAliases": false
},
"test": {
"username": "root",
"password": "12345",
"database": "fasttrack",
"host": "localhost",
"dialect": "mysql",
"define": {
"timestamps": false
},
"operatorsAliases": false
},
"production": {
"username": "root",
"password": "12345",
"database": "fasttrack",
"host": "localhost",
"dialect": "mysql",
"define": {
"timestamps": false
},
"operatorsAliases": false
}
}
内联连接声明
const sequelize = new Sequelize(config.database,config.username,config.password,{ host:config.host, 方言:config.dialect, 游泳池:{ 最大值:5, min:0, 空闲:10000 }, 记录:false, freezeTableName:true, 运营商意见:错误 });