JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 160
  • Score
    100M100P100Q97536F
  • License MIT

tegg transaction decorator

Package Exports

  • @eggjs/transaction-decorator
  • @eggjs/transaction-decorator/package.json

Readme

@eggjs/transaction-decorator

NPM version Known Vulnerabilities npm download Node.js Version

事务注解

Usage

传播机制

export class Foo {
  @Transactional({ propagation: PropagationType.ALWAYS_NEW })
  async bar() {
    await this.foo();
  }

  @Transactional({ propagation: PropagationType.REQUIRED })
  async foo(msg) {
    console.log('has msg: ', msg);
  }
}

数据源

export class Bar {
  @Transactional({ dataSourceName: 'xx' })
  async bar() {
    await this.foo();
  }
}

Foo.bar 始终会在一个独立的事务中执行,而 Foo.foo 会在 Foo.bar 的事务中执行