最后活跃于 1729145314

修订 1793888e2452df64d880aedd8c93efda2a8e2fe1

TypeORM-readme-24.ts 原始文件
1import { Photo } from "./entity/Photo"
2import { AppDataSource } from "./index"
3
4const photo = new Photo()
5photo.name = "Me and Bears"
6photo.description = "I am near polar bears"
7photo.filename = "photo-with-bears.jpg"
8photo.views = 1
9photo.isPublished = true
10
11const photoRepository = AppDataSource.getRepository(Photo)
12
13await photoRepository.save(photo)
14console.log("Photo has been saved")
15
16const savedPhotos = await photoRepository.find()
17console.log("All photos from the db: ", savedPhotos)
18