sequelize / sequelize-auto

Automatically generate bare sequelize models from your database.
2.9k stars 527 forks source link

Using --noAlias still keeps the name of association property as if it was aliased #644

Open TiLopes opened 1 year ago

TiLopes commented 1 year ago

Without --noAlias

init-models.ts -> Ocorrencias.belongsTo(Condomino, { as: "autor_condomino", foreignKey: "autor"});
ocorrencias.ts -> autor_condomino!: Condomino;

Everything works perfectly

With --noAlias

init-models.ts -> Ocorrencias.belongsTo(Condomino, { foreignKey: "autor"});
ocorrencias.ts -> autor_condomino!: Condomino;

const test_ocorrencia = await Ocorrencias.findOne({
   where: {
       id_condominio: req.condominioID,
       id: 3,
   },
   include: {
       model: Condomino,
   },
   nest: true,
});
logger.info(test_ocorrencia?.autor_condomino.nome_ocupante); -> returns undefined or just errors without ?.

Error I get if I try to use Condomino directly

UbTYf

Gists

TiLopes commented 1 year ago

Is there any progress on this issue?