Using Entity Manager
We just created a new photo and saved it in the database.We used EntityManager
to save it.Using entity manager you can manipulate any entity in your app.For example, let’s load our saved entity:
import {createConnection} from "typeorm";
import {Photo} from "./entity/Photo";
createConnection(/*...*/).then(async connection => {
/*...*/
let savedPhotos = await connection.manager.find(Photo);
console.log("All photos from the db: ", savedPhotos);
}).catch(error => console.log(error));
savedPhotos
will be an array of Photo objects with the data loaded from the database.
Learn more about EntityManager here.