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

143
Views
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
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!