import { AppDataSource } from "./index" // create photo object const photo = new Photo() photo.name = "Me and Bears" photo.description = "I am near polar bears" photo.filename = "photo-with-bears.jpg" photo.isPublished = true // create photo metadata object const metadata = new PhotoMetadata() metadata.height = 640 metadata.width = 480 metadata.compressed = true metadata.comment = "cybershoot" metadata.orientation = "portrait" photo.metadata = metadata // this way we connect them // get repository const photoRepository = AppDataSource.getRepository(Photo) // saving a photo also save the metadata await photoRepository.save(photo) console.log("Photo is saved, photo metadata is saved too.")