[英]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.