drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
23.49k stars 577 forks source link

[FEATURE]: unit of work #2543

Open khalvai opened 3 months ago

khalvai commented 3 months ago

Describe what you want

hi there i recentely heared about this orm by my friends and they are very interested. can i ask you how to implement unit of work by drizzel? i mean doing update multiple repositories in order failling one of them roll back all

class UOW {
userRepo:UserRepository
orderRepo:OrderRepsitory
startTransaction(){}
commitTransaction(){}
rollback()

}
class Test {

 main(){
 this.uow.startTransaction(){
      const a = await this.uow.UserRepo.create()

      const d = await this.uow.orderRepo.delete()

      this.uow.commitTransaction()

      // whetever the two will executed or the tow will rollbacked

      }
}

i saw you are handling transactions as prisma is doing, by passing a function but i don't perfer this way. i want to ask do you have any plane to add to support this kind of feature.

thanks