【发布时间】:2015-08-26 00:24:30
【问题描述】:
我正在尝试使用填充来返回引用到邮票模型的结果,在邮票的用户数组下,但由于某种原因,当我在数据库中看到邮票中的邮票 ID 列表时,它不会返回任何结果数组...
这是我的代码:
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) {
这是用户架构
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' }],
【问题讨论】: