Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

201
Vistas
Iterate array to save data in Firebase not working Angular

I'm trying to save data in firebase. I have an array from that I want to save data in firebase. When the size of the array is small it works but when the size is greater than 50 it is stuck and not responding to anything.

I have tried something like this

async handleOkCpy() {
    const modelId = this.cpyRadioValue;
    const mdlStgCopied = [];
    this.isCopying = true;
    let subscription;
    subscription = this.rcService.getSettingGroupData(this.cpyRadioValue).subscribe(
      async res => {
        const newAddedSetting = [];

        res.map(setting => {
          const index = this.settingGrpdata.findIndex(id => setting.id === id.id);
          if (index === -1) {
            newAddedSetting.push(setting);
          }
        });
        console.log('Get data');
        await Promise.all(
          newAddedSetting.map(async s => {
            console.log('Start');
            await this.rcService.copySetting(this.settingId, s.id, s.typeId, s.data);
            console.log('Done');
          })
        );

        console.log('here done');
        // await this.copyModelDiagram(modelId);
        this.nzMessageService.success('Settings has been copied successfully!');
        this.isCopying = false;

        // Unsubscribe observable to prevent infinite loopings
        subscription.unsubscribe();
      },
      err => {
        this.nzMessageService.error(err);
      }
    );
    this.isVisibleCpySett = false;
    this.cpyRadioValue = '';
  }

Myservice


  // copySetting
  copySetting(modelId, settGrpDocId, settingTypeId, settingData) {
    const serverTimeStamp = firebase.firestore.FieldValue.serverTimestamp();
    const data = {
      typeId: settingTypeId,
      data: settingData,
      updatedAt: serverTimeStamp,
      settingId: settGrpDocId
    };
    return this.afs
      .collection(`env/${currentENV.env}/baseModels`)
      .doc(modelId)
      .collection('settingsGroup')
      .doc(settGrpDocId)
      .set(data);
  }

According to the code, the start message is equal to done, but I'm getting different "done" each time I call my function.

I don't know what happens here.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda