i have question related mongodb.. currently, building rest api using node.js , express.js android app. database, using mongodb , mongoose... problem having can insert , print data using mongoose seems data inserted using mongoose not showing on mongodb..
what tried ran mongod , server.js on command line , inserted data using mongoose. , then, on command line, opened mongo --> use <dbname> --> db.<dbname>.find() shows nothing.. did wrong?? running mongod , server.js on localhost
-- edit
passport.use('signup', new localstrategy( { usernamefield : 'email', // name of username got passed strategy passwordfield : 'password', // name of password got passed tis strategy passreqtocallback : true }, function(req, email, password, done) { // done(...) ... (err, user, info) process.nexttick(function() { // find user username user.findone({ email : email }, function(err, user){ if(err) return done(err); if(user) return done(null, false, { message : 'user exists.' }); // save user var newuser = new user(); newuser.email = email; newuser.password = newuser.generatehash(password); newuser.save(function(err) { if(err) return done(err); return done(null, newuser); }); }); }); } ));
i using passport authentication , here inserting new user. tried print out users doing
user.find({}, function(err, users){ console.log(users); });
just try see new user inserted.. , see users log... however, if go command line mongo , db.user.find(), don't see anything.. thanks!
this how people create collection mongoose
var user = mongoose.model("user",userschema );
this create collection in mongoose called users
. make first letter lowercase ie: "u" , add "s". can check data db.users.find()
hope helps. don't know if know information.
it says here compiling first model.
the first argument singular name of collection model for. mongoose automatically looks plural version of model name.
this might help
Comments
Post a Comment