明树Git Lab

Commit 216111ef authored by zfp1's avatar zfp1

update

parent a2ca3d36
...@@ -14,12 +14,18 @@ ...@@ -14,12 +14,18 @@
async function batchCreate(req, res, next) { async function batchCreate(req, res, next) {
try { try {
let metals = req.body.metals; let metals = req.body.metals;
let ret = [];
if(metals && metals.length) {
ret = await DB.HeavyMetal.insertMany(metals);
} else {
let datas = req.body.datas;
let arr = []; let arr = [];
for (let index = 0; index < metals.length; index++) { for (let index = 0; index < datas.length; index++) {
const element = metals[index]; const element = datas[index];
arr.push({data: element}); arr.push({data: element});
} }
let ret = await DB.HeavyMetal.insertMany(arr); ret = await DB.HeavyMetal.insertMany(arr);
}
return res.sendData(ret); return res.sendData(ret);
} catch (error) { } catch (error) {
res.sendError(error); res.sendError(error);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment