Hi, so I’m working on a vocabulary app with Nextjs [not using mongoose] and each document contains a ObjectId, eng, kor, day, isDone, isMemorized values, and I’m fetching eng, kor rendering it alongside two buttons into an HTML table, one button is to display the definition and the other one to update the value of isMemorized to true
[Screenshot of how is rendered][https://i.imgur.com/V57BOxw.png] and here’s where my problem starts, so when I press the Memorize
button I’m making a PUT
request to update isMemorize
to true
so far I know the PUT
works as intended if I hard coded a random _id
like this
async function updateWord(req, res) {
const client = await clientPromise;
const db = client.db("dictionary");
await db
.collection("words")
.updateOne(
{ _id: ObjectId("62caa34849e3d70aa618d9f2") },
{ $set: { isMemorized: true } },
);
res.json({ status: 200 });
}
So my question is how can I make it, so the button only updates the isMemorized value of the document that’s inside that table?