Skip to content

typeorm


README#

sequalize와의 차이점 위주로 CRUD, 엔티티, repository, relation 위주로 빠르게 정리하겠습니다.

눈여겨 볼만한 주제들

  • entities & columns
  • entity manager?
  • repository
  • associations (relations)
  • eager & lazy relations
  • cascades

톺아보기...#

And your domain logic looks like this:

const userRepository = MyDataSource.getRepository(User);

const user = new User();
user.firstName = "Timber";
user.lastName = "Saw";
user.age = 25;
await userRepository.save(user);

const allUsers = await userRepository.find();
const firstUser = await userRepository.findOneBy({
    id: 1,
});
const timber = await userRepository.fineOneBy({
    firstName: "Timber",
    lastName: "Saw",
});
timber.age = 26;
await userRepository.save(timber);
const [users, userCount] = await userRepository.findAndCount();
await userRepository.remove(timber);

더 알아보기#