Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.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
Node.js 将firestore导出到传统的json文件中_Node.js_Firebase_Google Cloud Functions - Fatal编程技术网

Node.js 将firestore导出到传统的json文件中

Node.js 将firestore导出到传统的json文件中,node.js,firebase,google-cloud-functions,Node.js,Firebase,Google Cloud Functions,我试图做一些“老派”的事情,但是我不是Firebase或NodeJs方面的专家,所以需要专业人士的帮助 这是我的密码 exports.firest = functions.firestore .document('produkter/{produkterID}') .onUpdate((snap, context) => { const db = admin.firestore(); const produkterRef = db.collection('produ

我试图做一些“老派”的事情,但是我不是Firebase或NodeJs方面的专家,所以需要专业人士的帮助

这是我的密码

exports.firest = functions.firestore
 .document('produkter/{produkterID}')
 .onUpdate((snap, context) => {
     const db = admin.firestore();
     const produkterRef = db.collection('produkter');
     return produkterRef.get()
        .then((querySnapshot) => {
         const orders = [];
         querySnapshot.forEach(doc => {
             const order = doc.data();
             orders.push(order);
         });
         const json = JSON.stringify(orders);
         console.log(json)
         const blob = Buffer.from([json],{type:'application/json'});
          admin.storage().bucket('gs://aa.appspot.com').upload('produkter.json', {metadata: {blob}})
             admin.storage().bucket('gs://aa.appspot.com').put(blob).then(function(snapshot) {
             console.log('Uploaded a blob or file!');
         }) 
     });})

但这会在firebase函数控制台上产生错误。有人能帮我吗

这就是错误:

TypeError: admin.storage(...).bucket(...).put is not a function
at produkterRef.get.then (/srv/index.js:56:72)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:229:7)
TypeError:admin.storage(…).bucket(…).put不是函数
在produktref.get.then(/srv/index.js:56:72)
在
在进程中。_tickDomainCallback(internal/process/next_tick.js:229:7)

最诚挚的问候

错误消息告诉您对象上没有名为
put()
的方法

如果内存中有数据要上传,那么应该考虑创建一个对象并在其上使用


你也没有正确地处理承诺,所以除非你这样做,否则你会遇到其他问题。云函数要求您返回一个承诺,该承诺将在所有异步工作完成时解决。

您所问的问题似乎非常类似于,如果不是,您能否分享您得到的错误?“但这会在firebase函数控制台上产生错误。”=>请编辑您的问题,以包含准确的错误消息,以及完整的堆栈跟踪。另外,请仔细研究,因为您在这个问题上使用了相当多的复杂技术,如果您能够自己解决问题,更有可能有人能提供帮助。