What is EntityManager

Using EntityManager you can manage (insert, update, delete, load, etc.) any entity. EntityManager is just like a collection of all entity repositories in a single place.

You can access the entity manager via DataSource. Example how to use it:

import { DataSource } from "typeorm"
import { User } from "./entity/User"

const myDataSource = new DataSource(/*...*/)
const user = await myDataSource.manager.findOneBy(User, {
    id: 1,
})
user.name = "Umed"
await myDataSource.manager.save(user)

Copyright © runoops.com 备案号:闽ICP备19010956号-1 all right reserved,powered by GitbookFile Modify: 2024-09-11 17:40:30

results matching ""

    No results matching ""