Última atividade 1729143647

knox revisou este gist 1729143647. Ir para a revisão

1 file changed, 18 insertions

TypeORM-readme-2.ts(arquivo criado)

@@ -0,0 +1,18 @@
1 + const userRepository = MyDataSource.getRepository(User)
2 +
3 + const user = new User()
4 + user.firstName = "Timber"
5 + user.lastName = "Saw"
6 + user.age = 25
7 + await userRepository.save(user)
8 +
9 + const allUsers = await userRepository.find()
10 + const firstUser = await userRepository.findOneBy({
11 + id: 1,
12 + }) // find by id
13 + const timber = await userRepository.findOneBy({
14 + firstName: "Timber",
15 + lastName: "Saw",
16 + }) // find by firstName and lastName
17 +
18 + await userRepository.remove(timber)
Próximo Anterior