I'm facing a challenge with querying my database to extract a specific array element from within a user model. The schema is structured as follows:
const schemaUser = new mongoose.Schema({
username: { type: String, required: true, unique: true },
email: {type: String, unique: true},
password: { type: String, required: true},
accounts: [{
id : String,
account_name : String,
name : String,
password : String,
description: String
}]
});
Is there a way to query and retrieve a specific account from the "accounts" array based on its custom id (not the Mongodb one) that is associated with a particular user object?
Appreciate any guidance you can provide.