Skip to content

0018.4 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);

๋” ์•Œ์•„๋ณด๊ธฐ#

postgresql#