'How do I find certain information from array of objcetIds in mongoose
what i'm basically trying to do is to find out user with there username and also there role. but my problem here is its not a straight forward approach because what i have got inside schema is just the objectId of user and objectId of this role. how do I got about getting finding the user with a certain username and his role.
const GroupSchema = mongoose.Schema({
users: [
{
user: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
},
role: {
type: mongoose.Schema.Types.ObjectId,
ref: "Role",
},
},
],
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
