我一直是初学者,一直在尝试获取有关架构的响应。当我通过邮递员尝试POST方法时,我没有得到完整的答复,在某些领域中我还是一片空白。
router.post('/', async (req,res) => {
const exe = Exe.findById(req.body.exeId)
if(!exe) return res.status(404).send('Not found')
const test = new Test({
exe: {
_id: exe._id,
name: [exe.name],
date: exe.date,
location: {state: exe.state, country: exe.country}
},
testNumber: req.body.testNumber,
result: {pass: req.body.result.pass,university: req.body.result.university}})
res.send(test)
})
const resultSchema = new mongoose.Schema({pass: {type: Boolean}, university: {type: [String]}})
const testSchema = new mongoose.Schema({
exe: {type: new mongoose.Schema({
name: {type: [String],},
date: {type: Date,default: Date.now()},
location: {state: {type: String},country: {type: String}}
})},
testNumber: Number,
result: [resultSchema]
})
const Test = mongoose.model('Test', testSchema)
getting blanks on some fields, not able to get the complete response for all fields listed in schema.