firebase-admin 事务永远挂起

问题描述 投票:0回答:0

我正在尝试使用事务根据自身数据安全地改变文档。它以预期的空值运行一次,但之后它永远挂起,不再继续,不再运行回调,甚至不运行

onComplete
回调。

import * as fb from 'firebase-admin';

const fbApp = fb.initializeApp({
  projectId: 'my-project',
  databaseURL: 'https://my-project.firebaseapp.com'
});

await fbApp
.database()
.ref(`services/${serviceId}`)
.transaction(async (service: Service | null) => {
  console.log(service); // This runs only once and prints null

  if(service) {
    // Perform logic and mutate `service`
  }

  return service;
}, (e, what, data) => {
  console.log(e, what, data); // This never prints
});
node.js firebase-realtime-database firebase-admin
© www.soinside.com 2019 - 2024. All rights reserved.