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

141
Vistas
How to update boolean value in MongoDB database

I'm currently writing a Next.js, and I'm not sure how to update the isBookmarked boolean value in my code that will persist to the database from my component. Here's what I have currently.

Item.js

<Item>
...
<div onClick={????????}>....</div> //Update value on database from here
...
</Item>

index.js

export async function getServerSideProps(context){
  const client = await clientPromise;

  const db = client.db("mediaData")
  let media = await db.collection("media").find({}).toArray();
  media = JSON.parse(JSON.stringify(media));
  

  return{
    props:{ media} 
  }
}
......
media.map((item) => (
            <Item
              key={item._id}
              mediaBookmarked={item.isBookmarked} // value recived from the database
              year={item.year}
              category={item.category}
              rating={item.rating}
              title={item.title}
              small={item.thumbnail.trending.small}
              large={item.thumbnail.trending.large}
            />
....

Will I need to define a schema? I manually imported the information that populates this database from a JSON file.

about 4 years ago · Santiago Trujillo
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