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" });
发布于 2020-02-07 06:03:27
现在有了
一个图书馆
它插入到TypeORM中来帮助实现这一点。
https://stackoverflow.com/questions/46745688
复制相似问题