var list = new Array();
db.findMany(Scholarship, {}, {scholarship_type:1, _id:0}, function (resultArray) {
let list = resultArray.map(
(scholarship) => scholarship.scholarship_type);
console.log(list.toString());
});
//console.log(list.toString());
I have this code which uses the mongoose query findMany and if you see the first console log, it lists the actual array, but after running that query, it seems to return undefined.
This code is in my mongodb database connection, which is a CRUD operation for the db
/*
searches for multiple documents based on the model `model`
filtered through the object `query`
limits the fields returned based on the string `projection`
callback function is called after the execution of findMany() function
*/
findMany: function (model, query, projection, callback) {
model.find(query, projection, function (error, result) {
if (error) return callback(false);
return callback(result);
});
},