Is there any way to avoid nested properties in sequlize relations?

18 Views Asked by At

If you make this sequelize query:

await this.myModel.findAll({
      attributes: [
        'someAttribute'
      ]
      include: [anotherModel]
    })

You get a result like this:

{
   "someAttribute": "some data",
   "anotherrModel": {
     "attributesFromAnotherModel": "some data"
   }
}

Is there any way to avoid this behavior? I know i could modify this in Js, but the point here is make it with sequelize to avoid the need to make the request and then mutate the object. So the object that I'm thinking look like this:

{
   "someAttribute": "some data",
   "attributesFromAnotherModel": "some data"
}
0

There are 0 best solutions below