I have a query that doesn't seem to be working. I have gone to the mongo shell and seen that the database and the collection contain the data that I am after. Basically I do:
mongo
use form
var form = db.formDefintions.findOne()
form.formName
I try to do the equivalent with mongoose and it fails. This is what I am doing:
mongoose.connect('mongodb://localhost/form');
<define formDefinitionSchema>
var FormDefinition = mongoose.model('formDefinitions', formDefinitionSchema);
FormDefinition.findOne().exec(function(err, formDoc) {
if(err) {
throw err;
}
console.log(formDoc);
mongoFormName = formDoc.formName;
});
The callback doesn't return an error but 'formDoc' is always null. Does anything stand out that I am doing wrong? Any tips on how I might debug this?
Thank you.