My question is:
koa2 middleware '/info' ctx.res.body ------>front-end get
Object doesn't have dataValues and other value .only have object like {a:1,b:2}
In middleware I get ser
it have so many key-value like {dataValue:{a:1,b:2},eviousDataValues:'xxx'}
Why is the front-end Object not the same as 'ser' in ko2 middleware?
this is my code
let sequelize = new Sequelize('test', sqlOpt.name, sqlOpt.pwd, {
host: sqlOpt.host,
dialect: 'mysql',
port: sqlOpt.port,
pool: {
max: 5000,
min: 0,
idle: 10000
}})
let api = sequelize.define(
'api', {
id: {
type: Sequelize.STRING,
primaryKey: true
},
name: Sequelize.STRING,
method: Sequelize.STRING,
url: Sequelize.STRING,
description: Sequelize.STRING,
createTime: Sequelize.INTEGER,
did: Sequelize.STRING,
status: Sequelize.INTEGER,
content_type: Sequelize.INTEGER
}, {
freezeTableName: true,
tableName: 'apilist',
timestamps: false
})
module.exports = {
searchbyDid(params) {
return api.findAll({
where: {
did: params.id
}
})}}
router.get('/info', async ctx => {
let ser = await ser_m.searchAll()
for (let val of ser) {
val.dataValues.item = await api_m.searchbyDid({
id: val.id
})
}
ctx.response.body = ser
})