Answer the question
In order to leave comments, you need to log in
How to update data in mongodb via angular 8?
There is a UserService where all the data is stored. It is necessary to push certain data to the database when you click on the button.
For example, add different id to data.friends.
How can this be done? I've been sitting on this for hours and still can't figure it out.
Answer the question
In order to leave comments, you need to log in
I don't know the specifics of angular, but I looked here
https://jasonwatmore.com/post/2018/10/29/angular-7...
add different id to data.friends
User.updateOne(
{ _id: user_id },
{ $addToSet: // или $push?
{ friends:
$each: newFriendsIdArray // как-то так, чтобы каждый элемент массива добавился отдельно
}
}
)
No way. Angular is a frontend framework that runs in a browser, mongo is a database and all js libraries for it work on the backend, i.e. on node.js.
Send data from the browser with an http request to the backend, and already in it to the database.
From the front, you can only work with the database with firebase.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question