I have been racking my brain for a couple of hours now, I hope you can help me!
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
}
Neither the console.log table or constructs returns a what I expect.
constructs : undefined
table :