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

211
Views
Encuentre el registro a través de HorizonIO en RethinkDB que no devuelve el resultado

Tengo un MeetingService que obtiene datos de mi RethinkDB a través de HorizonIO. Cuando intento obtener una reunión a través de su ID, siempre obtengo un valor nulo como respuesta. Otros métodos en este servicio funcionan sin problemas.

servicio.de.reunión.ts:

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

reunión-detalle.component.ts:

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

Incluso cuando cambio passId a una ID que obtuve directamente de mi base de datos (a través del panel de administración), el método aún devuelve nulo.

Si cambio el código para que devuelva el primer valor de la tabla, todo simplemente funcionará.

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

El resultado final es un error indefinido en la variable currentMeeting en mi opinión:

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

Editar: código adicional que muestra las diferentes implementaciones:

 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]; } ); } }

El segundo funciona, el primero no. La identificación pasada es correcta y también está disponible en la base de datos, por lo que esto es bastante confuso.

Gracias por adelantado.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Aunque a nadie parece importarle la pregunta, encontré una respuesta que funciona relativamente bien. Mi solución temporal implicó obtener la tabla completa y encontrar manualmente la identificación correcta a través de un para cada uno, pero también es posible así:

  1. Cree una variable que sea un observable de la tabla que necesita (a través de .watch())
  2. Llame a flatMap() y obtenga la matriz observable (si alguien sabe por qué esto es necesario, hágamelo saber)
  3. Use find() y una lambda para llamar a la identificación correcta.

     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 Report
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!