Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

205
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda