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

140
Visualizações
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 à 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