Skip to content

Instantly share code, notes, and snippets.

View trillionclues's full-sized avatar
🏌️‍♂️
Cooking

Excel trillionclues

🏌️‍♂️
Cooking
View GitHub Profile
@trillionclues
trillionclues / updateNote.js
Created April 20, 2023 12:11
Gist to send and update specific node status by matching the Id in a database
// PUT ? UPDATE SPECIFIC NOTES
exports.dashboardUpdateNote = async (req, res) => {
try {
await Note.findOneAndUpdate(
{ _id: req.params.id },
{ title: req.body.title, body: req.body.body, updatedAt: Date.now() }
).where({ user: req.user.id })
res.redirect('/dashboard')
} catch (error) {
console.log(error)
@trillionclues
trillionclues / handleCheckboxChange.js
Created April 20, 2023 12:06
Handle checkbox change to validate if a todos has been checked as completed and moved to completed tab.
const handleCheckboxChange = (id) => {
const todoIndex = items.findIndex((item) => item.id === id)
const updatedItems = [...items]
updatedItems[todoIndex].completed = !updatedItems[todoIndex].completed
if (updatedItems[todoIndex].completed) {
setCompletedTodo([...completedTodo, updatedItems[todoIndex].id])
} else {
setCompletedTodo(completedTodo.filter((item) => item.id !== id))
}