javascript - Model.find() returning null json object in mongoose (mongodb) on node -
here's relevant code:
app.get('/all', function(req,res) { party.find({},[],function(p) { console.log(p); }); res.redirect('/'); });
should return collections database - returns null in console.
var mongoose = require('mongoose'); var db = mongoose.connect('mongodb://localhost/impromptu'); var schema = mongoose.schema, objectid = schema.objectid;
general stuff initialization
var partyschema = new schema({ : string, when : string, : string }); mongoose.model('party',partyschema); // models var party = db.model('party');
schema
i have else setup properly, can save collections fine, can't retrieve reason...
checked /var/log/mongodb.log , indeed connecting.
any ideas?
assuming you're using mongoose after v1.0 null err argument callback (there 2 ... first error results) ... try this:
party.find({},[],function(err,p) { console.log(p); });
Comments
Post a Comment