How to use the ember-cloud-firestore-adapter/utils/parser.flattenDocSnapshotData function in ember-cloud-firestore-adapter

To help you get started, we’ve selected a few ember-cloud-firestore-adapter 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 mikkopaderes / ember-cloud-firestore-adapter / addon / utils / realtime-tracker.js View on Github external
docRef.onSnapshot((docSnapshot) => {
        if (this.model[modelName].record[id].hasOnSnapshotRunAtLeastOnce) {
          if (docSnapshot.exists) {
            const record = store.peekRecord(modelName, id);

            if (record && !record.isSaving) {
              const flatRecord = flattenDocSnapshotData(docSnapshot);
              const normalizedRecord = store.normalize(modelName, flatRecord);

              store.push(normalizedRecord);
            }
          } else {
            this.unloadRecord(store, modelName, id);
          }
        } else {
          this.model[modelName].record[id].hasOnSnapshotRunAtLeastOnce = true;
        }
      }, (error) => {
        const record = store.peekRecord(modelName, id);
github mikkopaderes / ember-cloud-firestore-adapter / addon / adapters / cloud-firestore.js View on Github external
const unsubscribe = docRef.onSnapshot((docSnapshot) => {
        if (docSnapshot.exists) {
          if (this.getAdapterOptionConfig(snapshot, 'isRealtime') && !this.isFastBoot) {
            this.realtimeTracker.trackFindRecordChanges(type.modelName, docRef, store);
          }

          resolve(flattenDocSnapshotData(docSnapshot));
        } else {
          reject(new Error(`Record ${id} for model type ${type.modelName} doesn't exist`));
        }

        unsubscribe();
      }, error => reject(new Error(error.message)));
    });