node.js - Objects returned by Mongoose queries have no attributes -


i have 3 mongodb databases connect node.js app using mongoose.createconnection(...). each db, define schemas , models collections in db. problem have when query collection, results returned not have attributes set. however, using node-inspector, can see attributes loaded correctly db because present in _doc attribute.

example (some code omitted):

var mongoose = require('mongoose');  // connect db  var db = mongoose.createconnection(); var options = { auto_reconnect: true };  db.open(args.host, args.db, args.port, options, function(error, connection) {     var buildmodel = require('../models/' + dbname + '/schema.js');     buildmodel(db); }  // define schemas , models (in schema.js). `buildmodel` function above.  module.exports = function(mongoose) {     var group = new schema({         name: { type: string, required: true },         companyid: { type: objectid, required: true }     });      mongoose.model("group", group, 'groups'); };  // querying  var group = getdb('db1').model('group'); group.find({}, function(error, groups) {     // here documents in groups collection, attributes     // name , companyid not set.     groups.foreach(function(group) {         // name , companyid undefined         console.log('undefined' == typeof group.name); // true         console.log('undefined' == typeof group.companyid); // true          // _doc attribute populated         console.log(group._doc.name); // 'group 1'     }); }); 

the question is, forgetting when connect? have tried specify attributes fetch using populate after calling find, no success. using mongodb 2.4.3, node.js 0.10.6 , mongoose 3.6.11.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -