更新时间:2023-01-08 10:13:16
我认为这个问题与您的 最后一个问题,最简单的实现方法,将Location
实体添加到你的UserModule
I assume this question is related to your last question, the simplest way to implement it, Add Location
entity to your UserModule
@Module({
imports:[TypeOrmModule.forFeature([UserRepository,LocationRepository])], // or just Location entity [UserRepository,Location] if you didn't setup a custom LocationRepository
之后,将它注入到你的 userRepo... 服务中
After that, inject it in your as what you did for userRepo... service
constructor(
@InjectRepository(LocationRepository)
private locationRepository: LocationRepository,
// or just private locationRepository: Repository<Location>,
) {}
在创建方法服务中获取您的位置:
In the create method service get your locations:
async createUser(createUserDto: CreateUserDto) { // usersSrvice
let locations = await this.locationRepository.findByIds(createUserDto.locations);
await this.userRepository.createMethodeName(createUserDto,locations) // add secand
params for your locations
如果您有任何其他问题,请随时提出