I am completely new to mongo and node.js, so I'm still at the game stage.
I am running Windows 7, so I need to use Cygwin to use node.js. For mongo, I copied the binaries to the cygwin / bin / folder and started mongod - this still works. I can create databases, tables, etc.
Now I want to use Mongoose with node.js. I installed it through npm and it seems to work, but I cannot save my entries.
Here is the code I'm using:
var mongoose = require('mongoose'),
sys = require('sys'),
Schema = mongoose.Schema;
mongoose.connect('mongodb://localhost/test');
var User = new Schema({
name : String
});
mongoose.model('User', User);
var UserModel = mongoose.model('User');
var u = new UserModel();
u.name = 'John';
u.save(function(){
sys.puts('Saved!');
});
I never see my "saved"! and he does not save it. Any suggestions?
source
share