2021年3月24日星期三

How to get a list of movies sorted by popularity (favourited by most users) in mongoose?

I have following schema for a movie api project.

var MovieSchema = new Schema({      title: {          type: String,          required: true      },      description: {          type: String      },      genre: {          type: String      },      release_date: {          type: Date,          required: true      }  });  const userSchema = new Schema({      name: { type: String, required: true },      email: { type: String, required: true, unique: true },      password: { type: String, required: true, minlength: 6 },      favourite_movies: [{          type: Schema.Types.ObjectId,          ref: "Movie"      }]  });  

Please note that schema is hard to change because of other feature restrictions of project.

How to get a list of all movies sorted by popularity (favourited by most users) for this schema?

https://stackoverflow.com/questions/66792006/how-to-get-a-list-of-movies-sorted-by-popularity-favourited-by-most-users-in-m March 25, 2021 at 09:59AM

没有评论:

发表评论