gpt4 book ai didi

javascript - afterCreate 数据库 Hook 进程准备就绪后如何向客户端发送消息?

转载 作者:行者123 更新时间:2023-11-30 21:13:13 25 4
gpt4 key购买 nike

我有一个带有 sequelize(使用 postgres)REST 后端服务器的 express。当我从我的客户端发布一个创建请求时,数据库条目被创建,然后一个 afterCreate Hook 正在运行一个处理脚本大约一秒钟。使用 afterCreate Hook 形式 sequelize 运行良好。

随后,我需要让客户端知道处理已准备就绪,然后客户端将运行自己的一些进程。如何向客户发送消息?

最佳答案

我不是 Node 专家,我的回答可能是错误的,但基于 https://groundberry.github.io/development/2016/11/06/continue-building-your-node-app-with-express-and-sequelize.html你不能做以下事情吗:

router.post('/', function(req, res) {
//node return reply after running the create
return models.User.create({ username: req.body.username }).then(function() {
return res.json({ message: 'New user created' });
});
});

关于javascript - afterCreate 数据库 Hook 进程准备就绪后如何向客户端发送消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45922667/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com