Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 环回获取错误事务未激活_Mysql_Node.js_Transactions_Loopback - Fatal编程技术网

Mysql 环回获取错误事务未激活

Mysql 环回获取错误事务未激活,mysql,node.js,transactions,loopback,Mysql,Node.js,Transactions,Loopback,我已经为在模型(common/models/quote.js)中保存数据创建了自定义路由器路径。我想交易也为这个。所以我创建了这样的事务 quotation.save = async(reqBody, include, cb) => { try { await app.dataSources.db.transaction(async models => { const {quotation} = models; const {gu

我已经为在模型(common/models/quote.js)中保存数据创建了自定义路由器路径。我想交易也为这个。所以我创建了这样的事务

quotation.save = async(reqBody, include, cb) => {

    try {
      await app.dataSources.db.transaction(async models => {
        const {quotation} = models;
        const {guest} = models;

        const rollBack = (location, err) => {
          console.log(location);
          throw err;
        };

        await quotation.create(quotationJSON, (quotationErr, quotationResponse) => {
          if (quotationErr) {
            rollBack('Quotation Save Err', quotationErr);
          }
          var guestArray = quotationJSON.guestArray;
          guestArray.map(async(guestObj, guestIndex) => {
            guestObj.guest_quotation_ID = quotationResponse.id;
            if (quotationJSON.guestArray.length - 1 === guestIndex) {
              await guest.create(guestArray, (guestErr, guestResponse) => {
                if (guestErr) {
                  rollBack('Guest Save Err', guestErr);
                }
                console.log(guestResponse);
              });
            }
          });
        });
      });
    } catch (e) {
      console.log(e); // Oops
    }

  };
当这个运行时,它会给出这样一个错误

quotation.save = async(reqBody, include, cb) => {

    try {
      await app.dataSources.db.transaction(async models => {
        const {quotation} = models;
        const {guest} = models;

        const rollBack = (location, err) => {
          console.log(location);
          throw err;
        };

        await quotation.create(quotationJSON, (quotationErr, quotationResponse) => {
          if (quotationErr) {
            rollBack('Quotation Save Err', quotationErr);
          }
          var guestArray = quotationJSON.guestArray;
          guestArray.map(async(guestObj, guestIndex) => {
            guestObj.guest_quotation_ID = quotationResponse.id;
            if (quotationJSON.guestArray.length - 1 === guestIndex) {
              await guest.create(guestArray, (guestErr, guestResponse) => {
                if (guestErr) {
                  rollBack('Guest Save Err', guestErr);
                }
                console.log(guestResponse);
              });
            }
          });
        });
      });
    } catch (e) {
      console.log(e); // Oops
    }

  };
错误:事务未激活:5e59b5f0-8b7a-11ea-a422-b1cd47789f87

那么我该如何解决这个问题呢?

你能解决这个问题吗?