最後活躍 1729143647

knox 已修改 1729143647. 還原成這個修訂版本

1 file changed, 18 insertions

TypeORM-readme-2.ts(檔案已創建)

@@ -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)
上一頁 下一頁