skip to Main Content

Mongodb – Uncaught TypeError: Cannot read properties of undefined (reading 'map') while using map function in useEffect

useEffect(() => { if(currentUser){ currentUser?.friends.map(friends => { if(friends._id===currentProfile._id){ return setFriend(true) } }) }else{ return setFriend(false) } },[currentUser,currentProfile]) //currentUser is the user logged in //currentProfile is user selected i want to show button as Unfriend if the user selected is already…

VIEW QUESTION

Mongodb – Modifying mongoose result modifies all document instead of one

I have this function: const getXNumberOfDocuments = async function getXNumberOfDocuments( page, results_per_page ) { /*************************************************** */ results_per_page = parseInt(results_per_page); let x_number_of_documents = await Document.find() .populate([ { path: "user", populate: { path: "profile", select: ["profileImageURL"], }, }, ]) .limit(results_per_page) .skip(results_per_page *…

VIEW QUESTION
Back To Top
Search