从数据库中删除

让我们从数据库中删除我们的 Photo:

  1. import { createConnection } from "typeorm";
  2. import { Photo } from "./entity/Photo";
  3. createConnection(/*...*/)
  4. .then(async connection => {
  5. /*...*/
  6. let photoToRemove = await photoRepository.findOne(1);
  7. await photoRepository.remove(photoToRemove);
  8. })
  9. .catch(error => console.log(error));

这个id = 1的 photo 在数据库中被移除了。