如何在MySQL中插入多个logging/行
在Sails.js中可以插入多个logging吗? 我正在使用MySQL,我需要根据来自API的请求将“n”行保存到MySQL中。
我需要关于Sails.js的帮助谢谢
是的,你可以一次写入多个logging在MySQL中。 让我的模型是:
module.exports = { tableName:'test', autoCreatedAt:false, autoUpdatedAt:false, attributes: { name:'string' } };
首先让我们看看在mysql查询中是如何完成的。
INSERT INTO `test` VALUES (1,'AB'),(2,'ABCCDC');
现在这是如何添加多个logging…
Test.create([{name:'name1'},{name:'name2'},{name:'name3'}]) .exec(function(err,done){ if(err){ //hendle the error; return; } //successfully inserted; });
现在我想我的观点很清楚。
你只需要传递
array of objects in model.create()
来插入多个对象。
- 在Node.js / Express和AngularJS中创buildCORS请求
- 节点/ Javascript设置对象属性到数组不工作?
- 避免在javascript中循环多个返回 – asynchronous/等待解决callback金字塔或callback地狱,
- noflo:dynamic组件加载 – 组件不可用于base
- 需要帮助相关的asynchronous函数执行stream程(await,promises,node.js)
- Brunch将NODE_ENV或环境variables暴露给javascript
- 如何将此node.async代码转换为使用q? 我需要退还一个承诺吗?
- 如何访问swig上的主模型对象?
- 而与JavaScript循环