How to pessimistic locking

☆樱花仙子☆ 提交于 2021-01-29 18:00:43

问题


I want to lock my table, but it didn't work. How can I handle it? Appreciate any advice!

  • Typescript
  • Typeorm
  • Postgres
//src
    public async checkDBTable(builderAddress: string): Promise<boolean> {
        // 1. find DB table by key(builderAddress)
        // 2. return true({key: value} exist) or false
        const info: InfoEntity|undefined = await this.findOne(builderAddress, {
            lock: {mode: 'pessimistic_write'}
        });
        return nonceInfo !== undefined;
    }
//result
    error: PessimisticLockTransactionRequiredError: An open transaction is required for pessimistic lock.

来源:https://stackoverflow.com/questions/63296041/how-to-pessimistic-locking

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!