node.js - How do I get Mongoose to find none Mongoose created data within MongoDB? -
can please stop me going insane!
i have mongodb database has database created , populated via mongoose, works great can perform finds woth no problems @ all.
i went mongo console , created new database use newdb , performed simple insert, inserted several records , appeared fine within mongo. can find on them , mongo operations when try perform find on database mongoose returns null???
i have noticed database created in mongo console not create '__v' field believe mongoose internal indexing uses, have created field in custom tables still no joy cannot create data outside of mongoose , use within app??????
i have spent hours looking , reading maybe missed cannot find thing on , many people must hit every week????
**sorry here code running against database:
exports.adduser = function(req, res){ var mongoose = require("mongoose"); mongoose.connect("localhost/nm", function(err){ if(err)throw(err); console.log("connected mongodb successfully...") var schema = mongoose.schema({ firstname: string, lastname: string, middleinitial: string, password: string, username: string }); var auser = mongoose.model("users", schema); auser.find({}, function(err, alist){ console.log(">>>>"+alist); }); }); **
thanks again!!!!! input appreciated....
try inspecting mongo instance with
show dbs use <dbname> in mongo shell make sure using right database ,
show collections or alternatively
db.getcollectionnames() to see if collections there or not.
__v document version property incremented array operations(mongoose 3). connection string might wrong.
Comments
Post a Comment