TypeORM-readme-26.ts
· 304 B · TypeScript
Sin formato
import { Photo } from "./entity/Photo"
import { AppDataSource } from "./index"
const photoRepository = AppDataSource.getRepository(Photo)
const photoToUpdate = await photoRepository.findOneBy({
id: 1,
})
photoToUpdate.name = "Me, my friends and polar bears"
await photoRepository.save(photoToUpdate)
1 | import { Photo } from "./entity/Photo" |
2 | import { AppDataSource } from "./index" |
3 | |
4 | const photoRepository = AppDataSource.getRepository(Photo) |
5 | const photoToUpdate = await photoRepository.findOneBy({ |
6 | id: 1, |
7 | }) |
8 | photoToUpdate.name = "Me, my friends and polar bears" |
9 | await photoRepository.save(photoToUpdate) |