Monday, 7 October 2019

Relations using mongoose and mongoDB.

I have two Schemas in my API:const movieSchema = mongoose.Schema({ title: { type: String, required: true }, summary:{ type: String, required: true }, rating: { type: mongoose.Schema.Types.ObjectId, ref: 'Rating' } }); const ratingSchema = mongoose.Schema({ movie: { type: mongoose.Schema.Types.ObjectId, ref: 'Movie' }, score: { type: Number, required: true, min: 1, max: 10 }, publishDate: { type: Date } }); How can I get informations from ratingSchema into "rating" in movieSchema? I want there the score, date and in the future, a user that left the rating.

Submitted October 07, 2019 at 06:23PM by Snavvey

No comments:

Post a Comment