I have those code running try to save an object into MongoDB.
The .save()
never got success run. the code running fine.
.save()
method doesn't work.
var conn = mongoose.createConnection(mongoUrl, {auth: {authdb: "admin"}});
conn.on('error', function (err) {
throw err;
});
conn.once('open', function callback() {
console.log("connected to " + mongoUrl);
var cacheSchema = mongoose.Schema({}, {strict: false});
cacheSchema.set('collection', 'caches');
// you need to specify which connection is uing.
var Cache = conn.model('cache', cacheSchema);
var measure = new Cache();
measure['test'] = "test";
measure.save(function(err){
console.log('test');
});
});