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

212
Visualizações
Find record through HorizonIO in RethinkDB not returning result

I've got a MeetingService that fetches data from my RethinkDB through HorizonIO. When trying to fetch a meeting through its ID, I'll always get a null value as response. Other methods in this service work without issue.

meeting.service.ts:

getMeetingById(passedId: string): Observable<Meeting[]> {
    return this.table.find({meetingId: passedId}).fetch();
}

meeting-detail.component.ts:

currentMeeting: Meeting;

getCurrentMeeting(): void {
    this._meetingsService.getMeetingById(this.passedId).subscribe(
        (returnMeetings: Meeting[]) => {
            this.currentMeeting = returnMeetings[0];
        }
    );
}

Even when I change the passedId to an ID I got directly from my db (through the admin panel), the method still returns null.

If I change the code to return the first value in the table everything will simply work.

getMeetingById(passedId: string): Observable<Meeting[]> {
    return this.table.order("meetingId", "descending").limit(1).fetch();
}

The end result is error undefined on the currentMeeting var in my view:

EXCEPTION: Error in ./MeetingDetailComponent class MeetingDetailComponent - inline template:1:4 caused by: 
Cannot read property 'meetingId' of undefined

Edit: Additional code showing the different implementatations:

load() {
    if(this.passedId != null) {
      this._feedService.GetFeedById(this.passedId).subscribe(
          (returnFeed: Feed[]) => {
            this.currentFeed = returnFeed[0];
          }
      );
    } else {
      this._feedService.GetFirstFeed().subscribe(
          (returnFeed: Feed[]) => {
            this.currentFeed = returnFeed[0];
          }
      );
   }
}

Second one works, first one doesn't. The passed id is correct and and is also available in the database so this is quite confusing.

Thanks in advance.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Although no one seems to care for the question, I've found an answer that works relatively well. My temporary fix involved fetching the entire table and manually finding the right id through a for each but it's also possible like this:

  1. Create a variable that's an observable of the table you need (through .watch())
  2. Call flatMap() and fetch the observable array (if anyone knows why this is necessary please let me know)
  3. Use find() and a lambda to call the right id.

    getMeetingById(passedId: string): Observable<IMeeting> {
        var allMeetings: Observable<Meeting[]>;
        allMeetings = this.table.watch();
    
        return allMeetings.flatMap((meetings: IMeeting[]) => Observable.from(meetings))
                          .find((meeting: IMeeting) => (meeting.id == passedId));
    
    }
    
about 4 years ago · Santiago Trujillo Relatório
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