I have a simple method as follows to write to a mongodb database. It uses the Mongojs module. Everything seems fine with the exception of the last line. I'm getting "TypeError: Cannot call method 'save' of undefined" in the console. What could the problem be?
var db = require('mongojs').connect('mongodb://foo:bar@something.com:10027/foobar');
var saveImage = function(file, usr) {
var imagesCollection = db.collection('Images');
var Image = {};
Image.imageFileName = file;
Image.user = usr;
Image.date = new Date();
db.imagesCollection.save(Image);
}
exports.saveImage = saveImage;