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:

  1. import {createConnection} from "typeorm";
  2. import {Photo} from "./entity/Photo";
  3. createConnection(/*...*/).then(async connection => {
  4. /*...*/
  5. let savedPhotos = await connection.manager.find(Photo);
  6. console.log("All photos from the db: ", savedPhotos);
  7. }).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.