Hi all,
I am having a problem when trying to show my other columns in my .find() statement its only outputting the following, how do I make it show my other columns too that are shown in the query.
Console -
Express is running on port 3000
Mongoose connection open on mongodb://localhost:27017/test
School { _id: 5aa93d03f7f57e04503b4695 }
Model -
const mongoose = require('mongoose');
const schoolsSchema = new mongoose.Schema({
Boarders: {
type: String,
},
Gender: {
type: String,
},
Town: {
type: String,
},
});
module.exports = mongoose.model('School', schoolsSchema);
mongoose.Promise = global.Promise;
App.js
app.get('/console', (req, res, next) => {
School.find({"Boarders": {'$regex': 'No B'}, "Gender": {'$regex': 'Mixed'}, "Town": {'$regex': 'London'}}, {"_id": 0, "Boarders": 1, "Gender": 1, "Town": 1})
.exec(function (err, items) {
if (err) { return next(err); }
var myData = new School(req.body)
console.log('School', myData);
res.send('Check console.log for list of items');
});
});
Html app -
<h1>Select names to database<h1>
<form method="GET" action="/console">
<label>Select gender town <label>
<input type="submit" value="Select">
</form>