使用sequelize和nodejs更新多个logging?
使用node.js(v0.10.12)和sequelize(2.0.0-dev9),我想更新现有的数据库表中的属性。 从另一个SO讨论中,我能够一次只更新一个logging。 我把这个调用封装在for循环中,但是在for循环中更新了相同的logging。
有人可以帮我修改这个代码来更新所有符合search要求的logging吗? 以下是我的代码:
global.db.Task.find({ where: {"Cd": "match"} && {"Desc": null} }).on('success', function(task) { if (task) { // if the record exists in the db task.updateAttributes({ Desc: "New Upate" }).success(function() {}); } })
根据文档,你需要做一个BulkCreate:(未testing)
global.db.Task.update( {Desc: 'New Upate'}, //set attribute {cd: 'match', Desc: null} //where criteria ).success(function(affectedRows) { ... });
- MongoDB(可能的_id数量)
- 如何在页面加载中使用Javascript成功完成Ajax请求
- Node Js + MySql + Express – app.use(bodyParser()); 没有定义 – 错误build立连接到新的SQL方法
- 使用Node和Express进行基本的HTTP身份validation4
- 如何使用进度条快速上传大文件?
- Node.js服务器重新启动会丢弃会话
- Express + MongoDB – req.query的对象
- Node.js Express res.json到html页面?
- 如何在Express(Node.js)模板中为Internet Explorer保留有条件的CSS语句