Skip to content

Latest commit

 

History

History
19 lines (15 loc) · 539 Bytes

working-with-entity-manager.md

File metadata and controls

19 lines (15 loc) · 539 Bytes

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)