Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从mysql表中包含JSON数组的列执行Sequelize搜索_Mysql_Node.js_Json_Sequelize.js - Fatal编程技术网

从mysql表中包含JSON数组的列执行Sequelize搜索

从mysql表中包含JSON数组的列执行Sequelize搜索,mysql,node.js,json,sequelize.js,Mysql,Node.js,Json,Sequelize.js,在我的mysql表中,我有一个JSON类型的列 const monthlyProgress = sequelize.define("monthlyprogress", { . . . duration: { type: Sequelize.JSON } }); return monthlyProgress; 在这个“duration”列中,我有一个JSON对象数组 [{"time&quo

在我的mysql表中,我有一个JSON类型的列

const monthlyProgress = sequelize.define("monthlyprogress", {
    .
    .
    .
    duration: {
            type: Sequelize.JSON
          }
 });
return monthlyProgress;
在这个“duration”列中,我有一个JSON对象数组

[{"time":"nov-2020"},{"time":"dec-2020"}]
现在,我需要一个sequelize findall来获取条件将被忽略的行 time=“nov-2020”“持续时间”列的 我试过很多方法,但都失败了。下面我展示了我在stackoverflow上找到的一种方法。但这也是一次失败的尝试

它给了我那些没有time=“nov-2020”

这是显示此错误消息的另一次尝试未经处理的PromisejectionWarning:ReferenceError:JSON\u包含的内容未定义

await monthlyProgress.findAll({
        where: {
            [Op.and]: db.Sequelize.literal(JSON_CONTAINS(`duration`, '{\"time\": nov-2020}')),
        }
    })
await monthlyProgress.findAll({
        where: {
            [Op.and]: db.Sequelize.literal(JSON_CONTAINS(`duration`, '{\"time\": nov-2020}')),
        }
    })