简体   繁体   English

获取 `eslint' - 解析错误,同时编译 firebase 云 function

[英]Getting `eslint' - parsing error, while compiling firebase cloud function

Recently I've started working on a project based on firebase cloud functions and firestore database.最近我开始做一个基于firebase云函数和firestore数据库的项目。 I'm writing a cloud function trigger function which will query a "Collection group", on a new document being created.我正在编写一个云 function 触发器 function ,它将在正在创建的新文档上查询“集合组”。

Below is the cloud function code file:下面是云function代码文件:

exports.findDealsOnBuy = functions.firestore
    .document('businessmen/{businessmenId}/buy/{buyId}')
    .onCreate((snapshot, context) => {
        const businessmenId = context.params.businessmenId;
        const buyId = context.params.buyId;
        const buy = snapshot.data();
        functions.logger.info('businessmenId : ', businessmenId, ' buyId : ', buyId, ' buy : ', buy );
        const sellGrpRef = admin.firestore().collectionGroup('sell');
        const querySnapshot = await sellGrpRef.whereEqualTo('goodsName', '==', buy.getGoodsName())
            .whereEqualTo('goodsLocation', '==', buy.getGoodsLocation())
            .whereEqualTo('status', '==', 1)
            .whereEqualTo('status', '==', 5)
            .whereLessThanOrEqualTo('bestPrice', '<=', buy.getBestPrice())
            .orderBy('bestPrice', 'desc')
            .get();
            
            if (querySnapshot.empty) {
                console.log('No matching documents.');
                return;
            } 
            
            querySnapshot.forEach((doc) => {
                console.log(doc.id, ' => ', doc.data());
            });
    });

But while compiling i am being thrown the below error但是在编译时我被抛出以下错误

> C:\Users\Suman\Kamakshi\Ganesh\Burrabazar\Cloudfunctions\functions\index.js
> 31:31  error  Parsing error: Unexpected token sellGrpRef

I tried a lot but I am unable to find a clue how to resolve this.我尝试了很多,但我找不到如何解决这个问题的线索。 Requesting help to resolve.请求帮助解决。

I am sharing now that I found the await documentation in MDN Web Doc .我现在分享的是,我在MDN Web Doc中找到了 await 文档。

To wait for a Promise, use the await operator.要等待 Promise,请使用 await 运算符。 Within standard JavaScript code, it can only be used inside an async function.在标准 JavaScript 代码中,它只能在异步 function 中使用。

You can use await within a function if you use the async keyword before the function definition.如果在 function 定义之前使用 async 关键字,则可以在 function 中使用 await。 When you wait for a promise to settle, the function is stopped in a non-blocking manner.当您等待 promise 稳定时,function 以非阻塞方式停止。 You get the value back if the promise is kept.如果保留 promise,您将获得该值。 The rejected value is thrown if the promise fails.如果 promise 失败,则会抛出拒绝值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 包括异步 Function Firebase Cloud Functions 内(eslint“解析错误:意外的令牌函数”) - Including Async Function Within Firebase Cloud Functions (eslint "Parsing error: Unexpected token function") 解析功能触发器时出现Firebase错误 - Cloud Functions for Firebase Error occurred while parsing your function triggers Firebase 云 Function (Javascript) Firebase 部署时解析错误 - Firebase Cloud Function (Javascript) Parsing Error When Firebase Deploy 错误:在部署云功能时解析触发器时出错 - Firebase - Error: Error parsing triggers while deploying cloud functions - Firebase Firebase部署错误:解析函数触发器时发生错误 - Firebase Deploy Error: Error occurred while parsing your function triggers firebase部署错误:“解析函数触发器时发生错误” - firebase deployment error:“error occured while parsing your function triggers” 部署 Firebase 云发布订阅代码时出错 - getting error while deploying firebase cloud pub-sub code JavaScript Promise EsLint 部署 Firebase-Cloud-Function 时出现问题 - JavaScript Promise EsLint Problems when deploying Firebase-Cloud-Function Firebase 云 Function 不适用于 Prod。 得到错误 - Firebase Cloud Function isnt work in Prod. Getting error 错误:运行时出现“找不到模块” firebase 云 function - Error: "Cannot find module" while running firebase cloud function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM