Tuesday 23 May 2017

Get number of friends from MongoDB

I'm making MEAN app for the first time. I managed to insert users into MongoDB. Each user looks like:

{
"name":"My Name",
"country":"Italy",
"friends":"5922c66b4e708e27a02b7937"
}

My first question is, how to manualy insert more than one friend (how to separate them via Postman)?

Then I have html page to show those informations about user, so I display his friends that way:

<td></td>

When I will have more than one firend in database, how to display number of friends instead of their IDs?

Thanks for help!

EDIT: Solved the first part with

{
"friends":["5922c66b4e708e27a02b7937","5922c66b4e708e27a02b7937"]
}



via F. Mark

No comments:

Post a Comment