title: JavaScript: save entity, can it be written better?
body: <p>I have a method that saves in the user database. Because my database has relationships, I need user_id from UserEntity in the userAuth and userSalary tables so the <code>user</code> variable have to be first. But I want to return the whole User model with relations in response.</p>
  
  <p>Can you write this method more elegantly? like e.g Promise.all or anything functions in ES6+?</p>
  
  <pre><code>async createUser(userRegisterDto: UserRegisterDto): Promise&lt;UserEntity&gt; {
      const user = this.userRepository.create({ ...userRegisterDto });
      await this.userRepository.save(user);
  
      const userAuth = this.userAuthRepository.create({
          ...userRegisterDto,
          user,
      });
      await this.userAuthRepository.save(userAuth);
  
      const userSalary = this.userSalaryRepository.create({
          ...userRegisterDto,
          user,
      });
      await this.userSalaryRepository.save(userSalary);
  
      return user;
  }
  </code></pre>