我已经动脑了几个小时,希望您能帮我!
const Construct = require('../models/constructModel')
const TemplateConstruct = require('../models/constructTemplateModel')
exports.create = function () {
let universeConstructs = TemplateConstruct.get(async function (err, constructs) {
if (err) {
return false
} else {
let table = []
await constructs.forEach((construct) => {
let newconstruct = new Construct()
newconstruct.number = construct.number
newconstruct.name = construct.name
newconstruct.basePrice = construct.basePrice
newconstruct.baseMicrowave = construct.baseMicrowave
newconstruct.atomGain = construct.atomGain
newconstruct.save(function (err) {
if (err) {
return false
} else {
table.push(newconstruct)
}
})
})
console.log('table : ' + table)
return table
}
})
console.log('constructs : ' + universeConstructs)
return universeConstructs
}
console.log表或构造均未返回我期望的结果。
constructs : undefined
table :