I have a EJS page setup whereby a user makes various selections using buttons/text, and based on those options i want to query a mongoDB collection and return true if the users inputs match the data in an object?
form
<% layout('/layouts/boilerplate')%>
<form action="/caddy" method="get">
<div class="position">
<label for="tablePosition">Hero Position</label>
<input type="text" class="form-control" placeholder="Enter Your position" aria-label="Example text with two button addons">
<button type="button" class="btn heroBTN" id="btn">UTG</button>
<button type="button" class="btn heroBTN" id="btn">HJ</button>
<button type="button" class="btn heroBTN" id="btn" >LJ</button>
<button type="button" class="btn heroBTN" id="btn">CO</button>
<button type="button" class="btn heroBTN" id="btn">BTN</button>
<button type="button" class="btn heroBTN" id="btn">SB</button>
<button type="button" class="btn heroBTN" id="btn">BB</button>
</div>
<div>
<button submit="button" class="btn btn-primary">submit</button>
</div>
</form>
Schema
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const RangesSchema = new Schema({
position: String,
playertype: String,
unsuited_hands: [String],
suited_hands: [String]
});
module.exports = mongoose.model('Ranges', RangesSchema);
JS
router.get('/caddy', function(req, res) {
db.collection('rFI').find({"Position": { $regex: req.query.position ,$options: 'i' }}).toArray( (err, results) => {
console.log('got search')
res.send(results)});
});