【发布时间】:2022-10-05 23:20:31
【问题描述】:
我创建了一个 node.js 函数,可以在我的 firestore 数据库中查找文档,并且它可以成功运行,但我正在使用 .get() 查询它
有什么方法可以触发一个功能,该功能将等待完成,直到找到文档(因为文档是由不同的应用程序上传的)并设置在计时器上,这样如果计时器用完并且没有找到文档(比如说5 分钟)它会返回一个空文档值吗?
我当前的功能现在看起来像这样:
export const createFinder = async (latitude, longitude, orderUid) => {
// Find cities within 5km of location
const radiusInM = 50 * 100;
const bounds = geofire.geohashQueryBounds([latitude, longitude], radiusInM);
const promises = [];
for (const b of bounds) {
const q = db.collection(\'availableDocuments\')
.orderBy(\'geohash\')
.startAt(b[0])
.endAt(b[1]);
const snapshot = await q.get();
promises.push(snapshot);
}
return promises;
}
标签: node.js firebase google-cloud-firestore google-cloud-functions