How to use the firebase-admin.firestore.FieldPath function in firebase-admin

To help you get started, we’ve selected a few firebase-admin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github firebase / extensions / firestore-sharded-counter / functions / src / controller.ts View on Github external
await this.db.runTransaction(async (t) => {
      // Read all workers' metadata and contsruct sharding info based on collected stats.
      let query = await t.get(
        this.workersRef.orderBy(firestore.FieldPath.documentId())
      );
      let shardingInfo: WorkerShardingInfo[] = await Promise.all(
        query.docs.map(async (worker) => {
          const slice: Slice = worker.get("slice");
          const stats: WorkerStats = worker.get("stats");
          // This workers hasn't had a chance to finish its run yet. Bail out.
          if (!stats) {
            return {
              slice: slice,
              hasData: false,
              overloaded: false,
              splits: [],
            };
          }

          const hasData = true;