标签: geofirestore

在 Node 运行时 10 上部署 Firebase Cloud Functions 时出错,但在 Node 运行时 8 上工作

我正在尝试在我的云函数中实现 geofirestore。

这些函数在 Node 运行时 8 中部署正确,但在运行时 10 中部署时出现错误。

我的 index.js 标头如下:

const functions = require("firebase-functions");
const admin = require("firebase-admin");
const { GeoCollectionReference, GeoFirestore, GeoQuery, GeoQuerySnapshot } = require('geofirestore');
admin.initializeApp();

const db = admin.firestore();
const geofirestore = new GeoFirestore(db);
Run Code Online (Sandbox Code Playgroud)

我在 Node 运行时 10 上收到的错误消息是:

i  deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint

> functions@ lint C:\Users\naabr\Projects\flutter\mg_sos\firebase\functions
> eslint .

+  functions: Finished running predeploy script.
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API …
Run Code Online (Sandbox Code Playgroud)

node.js firebase google-cloud-functions google-cloud-firestore geofirestore

7
推荐指数
1
解决办法
6302
查看次数

Firestore - 我想动态地将 where 语句添加到我的集合中

技术:我正在使用 Angular 7、Firestore、GeoFireX。

我想要的结果:如果用户需要该查询,我想添加 .where 查询。例如下面我有四个 .wheres。有时我可能只需要两个,因此如果用户按部门和品牌搜索,我只想使用 if 语句添加两个(参见方法:basicQueryBuilder)

下面的代码有效,但不是动态的。

此外,来自 GeoFireX 的 this.geo.collection 是否可以像普通集合一样具有 .limit(20) ?

当前尝试:

  public getFirestoreJobs(queryType: string, limit: number, pageSize: number): Observable<any> {
    limit = limit + pageSize;

    if (queryType === 'geo') {
      const collection = this.geoQueryBuilder();
      const center = this.geo.point(51.5074, 0.1278);
      const radius = 20;

      return collection.within(center, radius, 'point');
    } else {
      const collection = this.basicQueryBuilder();

      return collection.valueChanges();
    }
  }

  public geoQueryBuilder(): any  {
    return this.geo.collection('jobs', ref => ref
      .where('sector', '==', 'teacher')
      .where('brand', …
Run Code Online (Sandbox Code Playgroud)

firebase geofire angular google-cloud-firestore geofirestore

4
推荐指数
1
解决办法
1966
查看次数

如何以正确的方式在Firebase Cloud-Functions中实现GeoFirestore?

我尝试将GeoFirestore实施到我的Firebase云功能。

当我尝试部署我的代码时,发生此错误“ TypeError:GeoFire不是构造函数”。

我将index.js文件用于功能。

我试图在我的函数中实现GeoFire参考,但这也无济于事...

我尝试了一切,但即时通讯无法解决此问题。我希望你们能帮助我:)

PS .:我为此帖子使用XXXXXXX更改了Firebase DatabaseURL。

我在网上搜索并找到堆栈溢出的答案,但是没有一个答案解决了我的问题。

我的index.js看起来像这样:

const functions = require('firebase-functions');
var admin = require('firebase-admin');
var serviceAccount = require('./serviceAccountKey.json');
var GeoFire = require('geofirestore');

admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://XXXXXXXXX.firebaseio.com"
});

admin.firestore().settings({
timestampsInSnapshots: true
});

const database = admin.firestore();
const Geo = new GeoFire(database.collection('UserLocations'));
Run Code Online (Sandbox Code Playgroud)

我的package.json依赖项如下所示:

"dependencies": {
"firebase-admin": "~6.0.0",
"firebase-functions": "^2.1.0",
"geofirestore": "^3.1.0"
},
Run Code Online (Sandbox Code Playgroud)

firebase google-cloud-functions geofirestore

3
推荐指数
1
解决办法
369
查看次数

Firestore 中的快照侦听器指标究竟如何工作?

以下是我在 Firestore 使用情况仪表板中看到的快照侦听器的内容

我正在构建一个 flutter 应用程序,并使用流来订阅 Firestore 查询结果。不幸的是,我不明白快照监听器指标是如何工作的,结合文档中的这个花絮:

https://firebase.google.com/docs/firestore/best-practices#realtime_updates

27 个峰值是否意味着我已经以某种方式创建了 27 个听众(当我应该创建一个时)?我很困惑。

另请注意,我与我的应用程序进行了 0 次交互,只是让它继续运行。

firebase google-cloud-firestore geofirestore

3
推荐指数
1
解决办法
2821
查看次数

按从最近到最远的顺序对 Firestore GeoHash 查询进行排序?

目前,我正在使用 GeoFirebase 库的部分内容以及 Firestore 来进行地理查询。当我设置帖子的 geohash 时,我是这样做的if let geoHash = GFGeoHash(location: location.coordinate).geoHashValue {

但是,为了使 geohash 查询不那么具体,我计划在查询时截断部分 geohash;目前,查询看起来与此类似

 var geoQuerySpecific = GFGeoHashQuery()
        let geoQueryHash =  GFGeoHashQuery.queries(forLocation: (lastLocation?.coordinate)!, radius: (30)) as! Set<GFGeoHashQuery>

        for query in geoQueryHash {
            geoQuerySpecific = query
            print("the key is this um \(geoQuerySpecific)")
        }
        print("the starting value is \(geoQuerySpecific.startValue)  and the end value is \(geoQuerySpecific.endValue)")
        let nearQuery = Firestore.firestore().collection("stuff").order(by: "g").whereField("g", isGreaterThanOrEqualTo: geoQuerySpecific.startValue).whereField("g", isLessThanOrEqualTo: geoQuerySpecific.endValue)
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,这将无法正常工作,因为 geoQueryHash 中有多个项目。当我在 firebase 中设置 geohash 时,我考虑过截断 geohash 的最后四位数字/字母,但是,这还不够具体。为了获得最接近的帖子,最好像我现在一样在数据库中设置 geoHashes,然后,在检索内容时,将起始值设置为查询的最具体的 geohash,然后将最终值设置为截断版本geohash,从获取最近的帖子开始并以最广泛的帖子结束?

我可以将 Firestore …

geolocation geohashing geofire google-cloud-firestore geofirestore

1
推荐指数
1
解决办法
2190
查看次数