javascript - 从 mongo 创建的对象在 psql 中输入数据
问题描述
我正在我的数据库中输入来自 mongo 的 _id 但答案很奇怪,当我
console.log(createdPlace._id);
我得到一个常规的答案
5f43b0fdc9d92c05282360a8
const addTodo = async (req, res, next) => {
const { content } = req.body;
const createdPlace = new Url({
content: content,
enable: false,
});
// Sending it To Mongo
try {
console.log(createdPlace._id);
await createdPlace.save();
await pool.query(
"INSERT INTO todo (todo_id ,content, enable) VALUES ($1, $2, $3)",
[createdPlace._id, content, false]
);
} catch (err) {
const error = new HttpError("Creating Place fails");
return next(error);
}
res.sendStatus(200);
};
数据库的输出是
{
"todo_id": "\"5f43b0fdc9d92c05282360a8\"",
"content": "first sending to with sasasddaame id",
"enable": false
}
这让我在 todo_id 末尾的这个“\”\“”发疯了希望得到帮助。
解决方案
推荐阅读
- android - 如何在条形图中启用滚动并将 xAxis 标签与条形组对齐?
- yii2 - Yii2 中的 ForbiddenHttpException 问题
- rdf - 我已经开发了一个本体——我该如何进行?
- django - 如何查询多个条件中的2个
- sql-server - 在创建表语句中动态打开/关闭标识
- javascript - RichEditor 使用 execCommand('bold') 两次附加额外标签
- ios - iOS/Swift 如何实时更新表格视图
- angular - 如何连接参数以链接到 mat-tab-nav-bar
- python - ValueError:未能找到可以处理输入的数据适配器:
, - php - ACF 默认值中的简码仅在保存帖子后才有效