【问题标题】:How to filter items by _id in MongoDB?如何在 MongoDB 中按 _id 过滤项目?
【发布时间】:2021-11-24 23:06:18
【问题描述】:

我自己制作了_ids:

该功能不起作用:

router.get('/getCompetitions', (request, response) => {
    competitionTemplateCopy.find({"_id": 1})
    .then(data => response.json(data))
    .catch(error => response.json(error))
});

【问题讨论】:

    标签: node.js reactjs mongodb


    【解决方案1】:

    试试这个:

        competitionTemplateCopy.find(_id:1)
        .then(data => response.json(data))
        .catch(error => response.json(error))
    });
    

    你应该在你的模型中添加 _id: { type: Number, },

    【讨论】:

      猜你喜欢
      • 2021-11-19
      • 2021-09-11
      • 1970-01-01
      • 2018-03-14
      • 1970-01-01
      • 1970-01-01
      • 2021-11-24
      • 1970-01-01
      • 2016-05-18
      相关资源
      最近更新 更多