Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!