Я хочу построить столбец запроса в одной строке.Я использовал приведенный ниже код в дальнейшем.Пожалуйста, помогите мне решить это.
<code>return Entity.userAddress.findAll({
where: {
'user_id': userAddress.user_id
},
include:[{
model: Entity.masterCountry,
required: true,
attributes: ['country_id', 'country_name'],
nested: true
},
{
model: Entity.masterState,
required: true,
attributes: ['state_id', 'state_name']
}]
})
.then((roleList) => {
return roleList;
})
This is my result when I have used above code.
<pre>
{
"code": 0,
"status": "success",
"data": [
{
"user_address_id": "04cec50e-4a2f-445f-b728-5ec8e914e322",
"user_id": "657d1823-1601-4072-863e-fd878f517d66",
"address1": "test1",
"address2": "test2",
"city_name": "chennai",
"masterState": {
"state_id": "b20dd34e-999e-445a-9b90-60246eefbd7e",
"state_name": "Alabama",
"short_name": "AL",
},
"masterCountry": {
"country_id": "aa656249-e0cf-4b40-ac35-8a5672475670",
"country_name": "United States"
}
}
]
}
Ожидаемые результаты должны быть такими, как показано ниже.Пожалуйста, помогите мне решить это.
{
"code": 0,
"status": "success",
"data": [
{
"user_address_id": "04cec50e-4a2f-445f-b728-5ec8e914e322",
"user_id": "657d1823-1601-4072-863e-fd878f517d66",
"address1": "test1",
"address2": "test2",
"city_name": "chennai",
"short_name": "AL"
"country_id": "aa656249-e0cf-4b40-ac35-8a5672475670",
"country_name": "United States"
}
]
}