Change rating to ratings which now is an array in User model
Add comments field in User model
Fix rating bug in ratedUsers
Implement endpoint for getting all ratings by user id (returns a list of all ratings as well as calculated overall rating)
/api/v1/users/<userId>/ratings
result: { "ratings": [ { "rating": 10, "_id": "611298147d859514554b2191", "user": "611296f002946e142d520501" }, { "rating": 2, "_id": "611298507d859514554b21a5", "user": "6112970d02946e142d520505" } ], "overall": 6 }
Implement endpoint for getting all comments by user id
/api/v1/users/<userId>/comments
result: [ { "_id": "61129e9a41e34414d98df3f8", "user": "611296f002946e142d520501", "comment": "An updated awesome experience review!" } ]
Changes:
rating
toratings
which now is an array in User modelcomments
field in User model/api/v1/users/<userId>/ratings
result:{ "ratings": [ { "rating": 10, "_id": "611298147d859514554b2191", "user": "611296f002946e142d520501" }, { "rating": 2, "_id": "611298507d859514554b21a5", "user": "6112970d02946e142d520505" } ], "overall": 6 }
/api/v1/users/<userId>/comments
result:[ { "_id": "61129e9a41e34414d98df3f8", "user": "611296f002946e142d520501", "comment": "An updated awesome experience review!" } ]
Tested with Postman