I'm not really sure how to name this problem but essentially I am using the Mongoose package for MongoDB and the function is not behaving. The function in question is:
var value = 'onetwothree'
model.findOne({ 'name': value }, callback)
which allows me to search the database for the attribute 'name'. However, if I try to pass 'name' in as a variable, the function doesn't work. For example, this doesn't work:
var attribute = 'name'
model.findOne({ attribute: value}, callback)
How do I call the findOne() function while making the attribute argument variable, i.e. I could pass in 'name', 'age', 'city', etc.