sequelize-typescript icon indicating copy to clipboard operation
sequelize-typescript copied to clipboard

Repository Mode - Error: Model not initialized

Open mwayne16 opened this issue 3 years ago • 0 comments

Issue

Versions

  • sequelize: 16.19.0
  • sequelize-typescript: 2.1.3
  • typescript: 4.6.4

Issue type

  • [x ] bug report
  • [ ] feature request

Actual behavior

When using repository mode and attempting to call other models from hooks or virtual fields, I get a model not initialized error. Ive tried using sequelize.getRepository(model), but that gives a "no default export defined for file some_model.ts" during the syncing process.

Expected behavior

Calling models from hooks and virtual fields working the same way they did without repository mode

Steps to reproduce

Try to call any Model or Repository from a hook or virtual field

Related code

	@Field()
	@Column({
		type: DataTypes.VIRTUAL,
		async get() {
			return PatientsRepository.findByPk(this.getDataValue('part_of'));
		},
	})
	parent_account: string;

mwayne16 avatar May 16 '22 20:05 mwayne16