'Counting total likes and whether a particular user has liked the nft?

I am trying to get the likes count of a nft and whether a particular user has liked it or not.

Likesmodel - `const NftCommentSchema = new Schema({
user_id: {
    type: Schema.Types.ObjectId,
    ref: 'users'
},
nft_id: {
    type: Schema.Types.ObjectId,
    ref: 'nfts'
},
comment: {
    type: String,
    default: null
},
created_at: {
    type: String,
    default: +new Date()
},

} )`

Likes model



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source