猫鼬发现没有获取任何结果

mongoose find not fetching any result

我在 mongo 中有简单的 collection 和相应的 mongoose 模型。此 collection 将始终只包含一个文档。当我 运行 在 mongoshell 中查询时,它给我结果,但是当我尝试使用 mongoose 执行 findOne 时,它​​根本不返回任何结果。有人可以帮我找出问题所在。下面是我的代码。

型号:

const mongoose = require('mongoose');
const schema = new mongoose.Schema({
    lastResetMonth: {
        type: Number
    },
    lastResetWeek: {
        type: Number
    },
    currentFisYear:{
        type: Number
    }
});
module.exports = mongoose.model('ReserveResetTrack', schema, 'reserveResetTrack');


const ReserveResetTrack = require('../models/ReserveResetTrack');

ReserveResetTrack.findOne({})
        .then(trackData => {
            return {
                lastFisMonth: trackData.lastMonth,
                lastFisWeek: trackData.lastWeek
            }
        });

上面的代码总是只返回一个承诺。

这是我 collection 中唯一的文档,并且这将是永远唯一的文档

{
    "_id" : ObjectId("589271a36bfa2da821b13ce8"),
    "lastMonth" : 0,
    "lastWeek" : 0,
    "currentYear" : 0
}

像这样使用exec()

ReserveResetTrack.findOne({})
    .exec()   // <--- use exec() here
    .then(trackData => {
        return {
            lastFisMonth: trackData.lastMonth,
            lastFisWeek: trackData.lastWeek
        }
    });