knox ha revisionato questo gist . Vai alla revisione
1 file changed, 18 insertions
TypeORM-readme-2.ts(file creato)
@@ -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) |
Più nuovi
Più vecchi