If you attempt to load a non-singleton Entity which does not exist, an EntityNotFoundError is thrown:
@Entity({ datastore })
class ComplexEntity {
@Column({ isPrimary: true })
public id: string
constructor(id: string) {
this.id = id
}
}
const complexRepository = getRepository(ComplexEntity)
const complexInstance = new ComplexEntity('12345')
await complexRepository.save(complexInstance)
await complexRepository.load('12345') // returns a new ComplexEntity instance
await complexRepository.load('99999') // throws EntityNotFoundError
This behaviour is not found with singleton Entities:
@Entity({ datastore })
class SingletonEntity {
// ...
}
const singletonRepository = getRepository(SingletonEntity)
const singletonInstance = new SingletonEntity()
await singletonRepository.load() // returns a new SingletonEntity instance <--
await singletonRepository.save(singletonInstance)
await singletonRepository.load() // returns a new SingletonEntity instance
Should the indicated line (<--) throw an EntityNotFoundError? If so, why? If not, why not?
If you attempt to load a non-singleton Entity which does not exist, an
EntityNotFoundErroris thrown:This behaviour is not found with singleton Entities:
Should the indicated line (
<--) throw an EntityNotFoundError? If so, why? If not, why not?