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

197
Vistas
Updating Fauna DB documents across child components

I have a ReactJS parent functional component that renders 6 child components via props. Via a NextJS API Route I'm able to render each FaunaDB document to each child component. One of the props is a "like count".

The problem is that I don't know how to write an API route that will allow the heart button on each component to update just that component's like count, if clicked. The reason for my difficulty is that the update API typically requires a document ref, but since there are 6 documents (one for each child component) that would mean 6 API Routes, which is inefficient.

What I want is one API for updating the like count, irrespective of the child component that is interacted with and 'like-count incremented' via a click.

How can I do this?


One option is to create a new document, which stores the like count for each paper by index and render that to the parent and child components. Then this collection can be referenced via the NextJS front-end. But I'm not sure how to conditionally render FaunaDB data so that the like count is displayed in the first place.

Another option is to create an Index from the document's Collection, but I'm not sure how to reference an Index from the front-end.


I think that the correct solution might map over an array of values and just change the particular value in question when the user clicks. But again, I'm not sure how you can selectively render a FaunaDB array to the NextJS / React front-end in the first place.


Note:

I don't mind re-writing the db data (manually) since it's a small dataset to begin with.

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