问题描述
我有一个待办事项列表作业,我想用2个具有相同数据的不同DB创建它。我如何在mongo和psql中具有相同的主键。我想在后端使用UUID来实现。有基本的方法吗?抱歉,我是初学者。
这是我的addToDo的示例,我如何拥有相同的主键?
const addTodo = async (req,res,next) => {
const { content } = req.body;
const createdPlace = new Url({
content: content,enable: false,});
// Sending it To Mongo
try {
await createdPlace.save();
await pool.query("INSERT INTO todo (content,enable) VALUES ($1,$2)",[
content,false,]);
} catch (err) {
const error = new HttpError("Creating Place fails mongo");
return next(error);
}
res.sendStatus(200);
};
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)