Answer the question
In order to leave comments, you need to log in
How to get data in mongoose?
Please tell me how to get the data, not in the form of an array with all the information suitable for the search result, but specific, as in this scheme, for example, get only the value of the name field?
const modelSchema = new Schema (
{
id: {
type: String,
required: true
},
name: {
type: String,
},
age: {
type: Number,
min: 18,
max: 90
},
cite: {
type: String
}
}
)
Answer the question
In order to leave comments, you need to log in
Actually I found a solution, here it is
Person.find({age:19})
.then(persons => {console.log(persons[0].name)})
and what hinders then simply to address to property name from the received object?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question