| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [View Raw Code] [Original HTTPS Page] |
You can create DELETE queries using QueryBuilder. Examples:
await myDataSource
.createQueryBuilder('users')
.delete()
.from(User)
.where("id = :id", { id: 1 })
.execute()This is the most efficient way in terms of performance to delete entities from your database.
Applying Soft Delete to QueryBuilder
await dataSource.getRepository(Entity).createQueryBuilder().softDelete()Examples:
await myDataSource
.createQueryBuilder('users')
.softDelete()
.where("id = :id", { id: 1 })
.execute();Alternatively, You can recover the soft deleted rows by using the restore() method:
await dataSource.getRepository(Entity).createQueryBuilder().restore()Examples:
await myDataSource
.createQueryBuilder('users')
.restore()
.where("id = :id", { id: 1 })
.execute();| Back | FazBrowse Home | New Git URL |