Последняя активность 1729143647

Версия 6c2b4c60188395fed7ee11fa335802b83bf7151e

TypeORM-readme-2.ts Исходник
1const userRepository = MyDataSource.getRepository(User)
2
3const user = new User()
4user.firstName = "Timber"
5user.lastName = "Saw"
6user.age = 25
7await userRepository.save(user)
8
9const allUsers = await userRepository.find()
10const firstUser = await userRepository.findOneBy({
11 id: 1,
12}) // find by id
13const timber = await userRepository.findOneBy({
14 firstName: "Timber",
15 lastName: "Saw",
16}) // find by firstName and lastName
17
18await userRepository.remove(timber)