node.js - Mongoose populate not returning results -


i trying use populate return results ref stamp model, under users array of stamps reason not return results when see in database list of stamp ids in stamps array...

here code:

var selectquery = "_id name";     var populatequery = [{path:'stamps', select: selectquery, model: 'stamp', }];     user.findone({_id: userid}).populate(populatequery).sort({date: -1}).skip(count).limit(100).exec(function(err, results) {         if(err) { 

here user schema

var mongoose = require('mongoose'), schema = mongoose.schema, objectid = mongoose.schema.types.objectid, var stamp = require('../models/stamp.js');  var user = new schema({      name: { type: string},      stamps: [{ type: objectid, ref: 'stamp' }], 

the "query" form of populate doesn't take array argument, object:

// `model` can left out mongoose in schema var populatequery = { path : 'stamps', select : selectquery }; 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -