Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.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 如何解决这个问题:获取值和类型错误_Mysql_Node.js_Express - Fatal编程技术网

Mysql 如何解决这个问题:获取值和类型错误

Mysql 如何解决这个问题:获取值和类型错误,mysql,node.js,express,Mysql,Node.js,Express,我想得到像“2”这样的值。但是Board.findOne({attributes:['deadline']},{where:{name:boardID}})打印'id:2'。我想解决这个问题 此外,我还有一个这样的打字错误。 TypeError:将循环结构转换为JSON -->从构造函数为“Sequelize”的对象开始 |属性“方言”->构造函数为“mysqldialent”的对象 ---属性“sequelize”结束循环 我怎样才能解决这个问题 router.post('/create/:b

我想得到像“2”这样的值。但是Board.findOne({attributes:['deadline']},{where:{name:boardID}})打印'id:2'。我想解决这个问题

此外,我还有一个这样的打字错误。 TypeError:将循环结构转换为JSON -->从构造函数为“Sequelize”的对象开始 |属性“方言”->构造函数为“mysqldialent”的对象 ---属性“sequelize”结束循环

我怎样才能解决这个问题

router.post('/create/:boardID', async (req,res,next) => {
const boardID = req.params.boardID;
try{
    const find = await Board.findOne({attributes: ['deadline']}, {where : {name : boardID}});
    const deadline = moment(find).format();
    if(moment(deadline).diff(moment().format()) < 0){
        const post = await Post.create({
            content : req.body.content,
            url : req.body.url
        });
        res.json(Object.values(find));
        const submit = await Submit.create({
            userId : req.body.userId,
            boardId : Object.values(find)
        });

        res.json(post + " : " + submit);
    } else {
        return res.json({req : false, msg : '기간이 지났습니다'});
    }
} catch (err) {
    console.error(err);
    next(err);
}
router.post('/create/:boardID',异步(req,res,next)=>{
const boardID=请求参数boardID;
试一试{
const find=await Board.findOne({attributes:['deadline']},{where:{name:boardID}});
const deadline=时刻(find).format();
if(时刻(截止日期).diff(时刻().format())<0){
const post=等待post.create({
内容:req.body.content,
url:req.body.url
});
res.json(Object.values(find));
const submit=等待提交。创建({
userId:req.body.userId,
boardId:Object.values(查找)
});
res.json(post+“:”+提交);
}否则{
返回res.json({req:false,msg:'기간이 지났습니다'});
}
}捕捉(错误){
控制台错误(err);
下一个(错误);
}

})

我认为,您在使用
findOne

const find = await Board.findOne({
   attributes: ['deadline'],
   where : {name : boardID}
});
const deadline = moment(find.deadline).format();
你可以试试这个