0

我有一个 Mongoose 查询,据我所知,它肯定应该可以工作,但是正在返回undefined,我不知道为什么。

这是查询:

...
var perPage = config.perpage;
var page = req.query.page > 0 ? req.query.page : 0;

db.Mail.find().select('-body -scraped').limit(perPage).skip(perPage * page).sort('-createdAt').exec(function (err, mail) {
...

这是模式以防万一:

var mongoose    = require("mongoose");
var timestamps  = require("mongoose-simpletimestamps").SimpleTimestamps;
var Schema      = mongoose.Schema;
var ObjectId    = Schema.ObjectId;

var oneday = 24 * 60 * 60;

var mailSchema = new Schema({
  subject: { type: String, required: true },
  body: { type: Schema.Types.Mixed, required: true },
  status: { type: String, required: true },
  processed: {
    area: {type: ObjectId, ref: 'Area'},
    url: String
  },
  scraped: { type: Schema.Types.Mixed },
  properties: [{ type: ObjectId, ref: 'Property' }],
  notifications: [{ type: ObjectId, ref: 'Notification' }],
  datestamp: {
    type: Number,
    default: function () { return Math.floor(Date.now() / oneday ); }
  }
});
mailSchema.plugin(timestamps);

module.exports = mongoose.model("Mail", mailSchema);

任何帮助将不胜感激,谢谢!

4

0 回答 0