TypeORM是否包含某些功能来避免这种情况:
let contraption = await thingRepository.findOne({ name : "Contraption" });
if(!contraption) // Create if not exist
{
let newThing = new Thing();
newThing.name = "Contraption"
await thingRepository.save(newThing);
contraption = newThing;
}
类似于:
let contraption = await thingRepository.upsert({ name : "Contraption" });